Documentation
¶
Overview ¶
Package client is an interface for any protocol's client
Index ¶
Constants ¶
const DefaultPoolSize = 50
DefaultPoolSize is 500
Variables ¶
This section is empty.
Functions ¶
func GetProtocolSpec ¶
GetProtocolSpec is to get protocol specifications
func InstallPlugin ¶
InstallPlugin is plugin for the new function
Types ¶
type NewFunc ¶
type NewFunc func(Options) ProtocolClient
NewFunc is function for the client
func GetClientNewFunc ¶
GetClientNewFunc is to get the client
type Options ¶
type Options struct {
PoolSize int
PoolTTL time.Duration
TLSConfig *tls.Config
Failure map[string]bool
}
Options is configs for client creation
type ProtocolClient ¶
type ProtocolClient interface {
Call(ctx context.Context, addr string, req *Request, rsp interface{}) error
String() string
}
ProtocolClient is the interface to communicate with one kind of ProtocolServer, it is used in transport handler rcp protocol client,http protocol client,or you can implement your own for example: rpc,it could be any client over any protocol,such as rpc over tcp ,rpc over http etc
func CreateClient ¶
func CreateClient(protocol, service string) (ProtocolClient, error)
CreateClient is for to create client based on protocol and the service name
func GetClient ¶
func GetClient(protocol, service string) (ProtocolClient, error)
GetClient is to get the client based on protocol and service name
type Request ¶
type Request struct {
ID int
MicroServiceName string
Schema string
Operation string
Arg interface{}
Metadata map[string]interface{}
}
Request is a struct for a protocol request to micro service server it includes common attribute for a protocol, usually, you should use Arg to wrap your real protocol request
func NewRequest ¶
NewRequest create common request,you can operate it in you own Call method of a ProtocolClient