client

package
v1.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2020 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Overview

Package client is an interface for any protocol's client

Index

Constants

View Source
const DefaultPoolSize = 512

DefaultPoolSize is 500

Variables

View Source
var ErrCanceled = errors.New("request cancelled")

ErrCanceled means Request is canceled by context management

View Source
var ErrClientNotExist = errors.New("client not exists")

ErrClientNotExist happens if client do not exist

Functions

func Close added in v0.8.1

func Close(protocol, service, endpoint string) error

Close close a client conn

func GetFailureMap added in v1.0.1

func GetFailureMap(p string) map[string]bool

GetFailureMap return failure map

func GetMaxIdleCon added in v1.3.0

func GetMaxIdleCon(p string) int

GetMaxIdleCon get max idle connection number you defined default is 512

func InstallPlugin

func InstallPlugin(protocol string, f NewFunc)

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

func GetClientNewFunc(name string) (NewFunc, error)

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

func EqualOpts added in v1.3.0

func EqualOpts(oldOpts, newOpts Options) Options

EqualOpts equal newOpts and oldOpts

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL