Documentation ¶
Index ¶
- Variables
- type CliPool
- type Option
- type ServerInfo
- type ZrpcClient
- func (cli *ZrpcClient) Close() error
- func (cli *ZrpcClient) Decorator(name string, i interface{}, retry int) error
- func (cli *ZrpcClient) GetSerivce(name string) (interface{}, bool)
- func (cli *ZrpcClient) Identity() string
- func (cli *ZrpcClient) Send(p *zrpc.Pack) (string, error)
- func (cli *ZrpcClient) SpecifySend(id string, p *zrpc.Pack) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrClientConnectClosed = errors.New("client connect is closed") ErrNoServer = errors.New("no service can be invoked") )
View Source
var ( ErrTooFewParam = errors.New("zrpc-cli: too few parameters") ErrTooFewReturn = errors.New("zrpc-cli: too few return values") ErrInvalidParamType = errors.New("zrpc-cli: the first param must be Context") ErrInvalidResultType = errors.New("zrpc-cli: the last return value must be error") )
View Source
var ( // ErrClosed client is closed ErrClosed = errors.New("zrpc-cli: client is closed") )
View Source
var ( // ErrPoolTimeout timed out waiting to get a client from the client pool. ErrPoolTimeout = errors.New("zrpc-cli: connection pool timeout") )
Functions ¶
This section is empty.
Types ¶
type CliPool ¶
type CliPool struct {
// contains filtered or unexported fields
}
func NewDirectPool ¶
func NewDirectPool(server ServerInfo, opt ...Option) (*CliPool, error)
NewDirectPool 连接池(只适用于单节点)
func (*CliPool) GetSerivce ¶
GetSerivce 获取已注册 rpc 服务实例以供使用
type ServerInfo ¶
type ZrpcClient ¶
type ZrpcClient struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(discover zrpc.ServiceDiscover) (*ZrpcClient, error)
NewClient 使用注册/发现中心创建客户端
func NewDirectClient ¶
func NewDirectClient(server ServerInfo) (*ZrpcClient, error)
NewDirectClient 根据 rpc 服务地址连接的客户端(只适用于单节点服务)
func (*ZrpcClient) Close ¶
func (cli *ZrpcClient) Close() error
func (*ZrpcClient) Decorator ¶
func (cli *ZrpcClient) Decorator(name string, i interface{}, retry int) error
Decorator 将 server proxy 装饰为可调用 server
func (*ZrpcClient) GetSerivce ¶
func (cli *ZrpcClient) GetSerivce(name string) (interface{}, bool)
GetSerivce 获取已注册 rpc 服务实例以供使用
func (*ZrpcClient) Identity ¶
func (cli *ZrpcClient) Identity() string
func (*ZrpcClient) SpecifySend ¶
func (cli *ZrpcClient) SpecifySend(id string, p *zrpc.Pack) error
SpecifySend 向指定服务节点发送 pack
Click to show internal directories.
Click to hide internal directories.