Documentation
¶
Overview ¶
Package client is an interface for any protocol's client
Index ¶
- Constants
- Variables
- func Close(protocol, service, endpoint string) error
- func GetFailureMap(p string) map[string]bool
- func GetMaxIdleCon(p string) int
- func InstallPlugin(protocol string, f NewFunc)
- func SetTimeoutToClientCache(spec *model.IsolationWrapper)
- type NewFunc
- type Options
- type ProtocolClient
- type TransportFailure
Constants ¶
const DefaultPoolSize = 512
DefaultPoolSize is 500
Variables ¶
var ErrCanceled = errors.New("request cancelled")
ErrCanceled means Request is canceled by context management
var ErrClientNotExist = errors.New("client not exists")
ErrClientNotExist happens if client do not exist
Functions ¶
func GetFailureMap ¶ added in v1.0.1
GetFailureMap return failure map
func GetMaxIdleCon ¶ added in v1.3.0
GetMaxIdleCon get max idle connection number you defined default is 512
func InstallPlugin ¶
InstallPlugin is plugin for the new function
func SetTimeoutToClientCache ¶ added in v1.3.0
func SetTimeoutToClientCache(spec *model.IsolationWrapper)
SetTimeoutToClientCache set timeout to client
Types ¶
type NewFunc ¶
type NewFunc func(Options) (ProtocolClient, error)
NewFunc is function for the client
func GetClientNewFunc ¶
GetClientNewFunc is to get the client
type Options ¶
type Options struct {
Service string
PoolSize int
Timeout time.Duration
Endpoint string
PoolTTL time.Duration
TLSConfig *tls.Config
Failure map[string]bool
}
Options is configs for client creation
type ProtocolClient ¶
type ProtocolClient interface {
// TODO use invocation.Response as rsp
Call(ctx context.Context, addr string, inv *invocation.Invocation, rsp interface{}) error
String() string
Close() error
ReloadConfigs(Options)
GetOptions() Options
}
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
func CreateClient ¶
func CreateClient(protocol, service, endpoint string) (ProtocolClient, error)
CreateClient is for to create client based on protocol and the service name
func GetClient ¶
func GetClient(protocol, service, endpoint string) (ProtocolClient, error)
GetClient is to get the client based on protocol, service,endpoint name
type TransportFailure ¶ added in v1.1.1
type TransportFailure struct {
Message string
}
TransportFailure is caused by client call failure for example: resp, err = client.Do(req) if err is not nil then should wrap original error with TransportFailure
func (TransportFailure) Error ¶ added in v1.1.1
func (e TransportFailure) Error() string
Error return error message