Documentation ¶
Overview ¶
Package client is an interface for any protocol's client
Index ¶
- Variables
- type CallOption
- type CallOptions
- type Client
- type Option
- func ContentType(ct string) Option
- func DialTimeout(d time.Duration) Option
- func PoolSize(d int) Option
- func PoolTTL(d time.Duration) Option
- func RequestTimeout(d time.Duration) Option
- func Retries(i int) Option
- func TLSConfig(t *tls.Config) Option
- func Transport(t microTransport.Transport) Option
- func WithCodecs(c map[string]codec.Codec) Option
- func WithConnectionPoolSize(n int) Option
- func WithFailure(m map[string]bool) Option
- type Options
- type PublishOptions
- type Request
- type RequestOption
- type RequestOptions
- type Response
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultRetries is the default number of times a request is tried DefaultRetries = 1 // DefaultRequestTimeout is the default request timeout DefaultRequestTimeout = time.Second * 5 // DefaultPoolSize sets the connection pool size DefaultPoolSize = 50 // DefaultPoolTTL sets the connection pool ttl DefaultPoolTTL = time.Minute )
Functions ¶
This section is empty.
Types ¶
type CallOption ¶
type CallOption func(*CallOptions)
CallOption used by Call or Stream
func WithContentType ¶
func WithContentType(ct string) CallOption
func WithDialTimeout ¶
func WithDialTimeout(d time.Duration) CallOption
WithDialTimeout is a CallOption which overrides that which set in Options.CallOptions
func WithMethodType ¶
func WithMethodType(s string) CallOption
func WithRequestTimeout ¶
func WithRequestTimeout(d time.Duration) CallOption
WithRequestTimeout is a CallOption which overrides that which set in Options.CallOptions
func WithRetries ¶
func WithRetries(i int) CallOption
WithRetries is a CallOption which overrides that which set in Options.CallOptions
func WithUrlPath ¶
func WithUrlPath(s string) CallOption
type CallOptions ¶
type CallOptions struct { Message []byte ContentType string // Transport Dial Timeout DialTimeout time.Duration // Number of Call attempts Retries int // Request/Response timeout RequestTimeout time.Duration // Other options for implementations of the interface // can be stored in a context Context context.Context Header map[string]string UrlPath string MethodType string }
type Client ¶
type Client interface { Init(...Option) error Options() Options NewRequest(service, schemaID, operationID string, arg interface{}, reqOpts ...RequestOption) *Request Call(ctx context.Context, addr string, req *Request, rsp interface{}, opts ...CallOption) error String() string }
Client is the interface used to make requests to services. It supports Request/Response via Transport rcp client,rest client,or you can implement your own for rpc,it could be any client over any protocol,such as rpc over tcp ,rpc over http etc
type Option ¶
type Option func(*Options)
Option used by the Client
func RequestTimeout ¶
The request timeout. Should this be a Call Option?
func Transport ¶
func Transport(t microTransport.Transport) Option
Transport to use for communication e.g http, rabbitmq, etc
func WithConnectionPoolSize ¶
func WithFailure ¶
type Options ¶
type Options struct { // Used to select codec ContentType string // Plugged interfaces Codecs map[string]codec.Codec //TODO ClientCodecs map[string]codec.NewClientCodec Transport microTransport.Transport // Connection Pool PoolSize int PoolTTL time.Duration // Default Call Options CallOptions CallOptions // Other options for implementations of the interface // can be stored in a context Context context.Context TLSConfig *tls.Config Failure map[string]bool }
type PublishOptions ¶
type Request ¶
type Request struct { ID int MicroServiceName string Struct string Method string Arg interface{} Metadata map[string]interface{} }
Request is a struct for request APIs of micro service
type RequestOption ¶
type RequestOption func(*RequestOptions)