Documentation ¶
Index ¶
- type CallOption
- func WithCallCodec(scheme string) CallOption
- func WithCallJsonRpc2() CallOption
- func WithCallJsonRpc2Writer() CallOption
- func WithCallLRPCMuxWriter() CallOption
- func WithCallLRPCNoMuxWriter() CallOption
- func WithCallPacker(scheme string) CallOption
- func WithCallWriter(writer msgwriter2.Writer) CallOption
- type Client
- func (c *Client) AsyncCall(service string, args []interface{}, ...) error
- func (c *Client) BindFunc(sourceName string, i interface{}) error
- func (c *Client) Call(service string, args ...interface{}) ([]interface{}, error)
- func (c *Client) Close() error
- func (c *Client) RawCall(service string, args ...interface{}) ([]interface{}, error)
- func (c *Client) Request(service string, ctx context.Context, request interface{}, response interface{}, ...) error
- func (c *Client) Requests(service string, requests []interface{}, responses []interface{}, ...) error
- type Complete
- type Config
- type Option
- func DirectConfig(uCfg Config) Option
- func WithAddress(addr string) Option
- func WithBalance(scheme string) Option
- func WithCodec(scheme string) Option
- func WithConsistentHashBalance() Option
- func WithCustomLogger(logger logger.LLogger) Option
- func WithDefault() Option
- func WithDefaultKeepAlive() Option
- func WithErrHandler(eh perror.LErrors) Option
- func WithFileResolver(url string) Option
- func WithHashLoadBalance() Option
- func WithHttpResolver(url string) Option
- func WithJsonRpc2() Option
- func WithJsonRpc2Writer() Option
- func WithKeepAlive(timeOut time.Duration) Option
- func WithLiveResolver(url string) Option
- func WithMessageParser(scheme string) Option
- func WithMessageWriter(writer msgwriter2.Writer) Option
- func WithMuxConnection(ok bool) Option
- func WithMuxConnectionNumber(n int) Option
- func WithMuxWriter() Option
- func WithNetWork(network string) Option
- func WithNoMuxWriter() Option
- func WithNoStackTrace() Option
- func WithOrderSelector() Option
- func WithPacker(scheme string) Option
- func WithPlugin(plugin plugin.ClientPlugin) Option
- func WithPoolSize(size int) Option
- func WithProtocol(scheme string) Option
- func WithRandomBalance() Option
- func WithRandomSelector() Option
- func WithResolver(bScheme, url string) Option
- func WithRoundRobinBalance() Option
- func WithStackTrace() Option
- func WithTlsClient(tlsC *tls.Config) Option
- func WithTraitMessageParser() Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallOption ¶
type CallOption func(cc *callConfig)
func WithCallCodec ¶
func WithCallCodec(scheme string) CallOption
func WithCallJsonRpc2 ¶
func WithCallJsonRpc2() CallOption
func WithCallJsonRpc2Writer ¶
func WithCallJsonRpc2Writer() CallOption
func WithCallLRPCMuxWriter ¶
func WithCallLRPCMuxWriter() CallOption
func WithCallLRPCNoMuxWriter ¶
func WithCallLRPCNoMuxWriter() CallOption
func WithCallPacker ¶
func WithCallPacker(scheme string) CallOption
func WithCallWriter ¶
func WithCallWriter(writer msgwriter2.Writer) CallOption
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 在Client中同时使用同步调用和异步调用将导致同步调用阻塞某一连接上的所有异步调用 请求的发送
func (*Client) AsyncCall ¶
func (c *Client) AsyncCall(service string, args []interface{}, callBack func(results []interface{}, err error)) error
AsyncCall TODO 改进这个不合时宜的API AsyncCall 该函数返回时至少数据已经经过Codec的序列化,调用者有责任检查error 该函数可能会传递来自Codec和内部组件的错误,因为它在发送消息之前完成
func (*Client) Call ¶
Call 返回的error可能是由Server/Client本身产生的, 也有可能是调用用户过程返回的, 这些都会被Call 视为错误, args为用户参数, 即context.Context & stream.LStream都会被放置在此, 如果存在的话. Call实现context.Context传播的语义, 即传递的Context cancel时, client会同时将server端的 Context cancel, 但不会影响到自身的调用过程, 如果cancel之后, remote process不返回, 那么这次调用将会阻塞 注册了元信息的过程返回的result数量始终等于自身结果数量-1, 因为error不包括在reps中, 不管发生了什么错误, 除非 找不到注册的元信息
func (*Client) RawCall ¶
RawCall 该调用和Client.Call不同, 这个调用不会识别Method和对应的in/out list 只会对除context.Context/stream.LStream外的args/reps直接序列化
type Config ¶
type Config struct { // Tls相关的配置 TlsConfig *tls.Config // 服务器的地址 // 当配置了地址解析器和负载均衡器的时候,此项将被忽略 ServerAddr string // 使用的日志器 Logger logger.LLogger // 连接池中的连接是否使用KeepAlive KeepAlive bool // 发送ping消息的间隔 KeepAliveTimeout time.Duration // 底层使用的Goroutine池的大小 PoolSize int32 // 客户端使用的传输协议 NetWork string // 字节流编码器 Packer packer.Packer // 结构化数据编码器 Codec codec.Codec // 用于连接复用的连接数量 MuxConnection int // 是否开启负载均衡 OpenLoadBalance bool // 使用的负载均衡器 BalancerFactory balancer.Factory // 使用的地址解析器 ResolverFactory resolver.Factory // 负责维护节点连接的选择器 SelectorFactory selector.Factory // 地址解析器解析地址时需要用到的Url ResolverParseUrl string // 安装的插件 Plugins []plugin.ClientPlugin // 可以生成自定义错误的工厂回调函数 ErrHandler perror.LErrors // 自定义Goroutine Pool的建造器, 在客户端不推荐使用 // 在不需要使用异步回调模式时可以关闭 ExecPoolBuilder pool.TaskPoolBuilder[string] Writer msgwriter.Writer ParserFactory msgparser.Factory // 是否启用调试模式 Debug bool }
type Option ¶
type Option func(config *Config)
func DirectConfig ¶
DirectConfig 这个接口不保证兼容性, 应该谨慎使用 Config中的内容可能会变动, 或者被修改了语义
func WithAddress ¶
func WithBalance ¶
func WithConsistentHashBalance ¶
func WithConsistentHashBalance() Option
func WithCustomLogger ¶
func WithDefault ¶
func WithDefault() Option
func WithDefaultKeepAlive ¶
func WithDefaultKeepAlive() Option
func WithErrHandler ¶
func WithFileResolver ¶
func WithHashLoadBalance ¶
func WithHashLoadBalance() Option
func WithHttpResolver ¶
func WithJsonRpc2 ¶
func WithJsonRpc2() Option
func WithJsonRpc2Writer ¶
func WithJsonRpc2Writer() Option
func WithKeepAlive ¶
func WithLiveResolver ¶
func WithMessageParser ¶
func WithMessageWriter ¶
func WithMessageWriter(writer msgwriter2.Writer) Option
func WithMuxConnection ¶
func WithMuxConnectionNumber ¶
func WithMuxWriter ¶
func WithMuxWriter() Option
func WithNetWork ¶
func WithNoMuxWriter ¶
func WithNoMuxWriter() Option
func WithNoStackTrace ¶
func WithNoStackTrace() Option
func WithOrderSelector ¶
func WithOrderSelector() Option
func WithPacker ¶
func WithPlugin ¶
func WithPlugin(plugin plugin.ClientPlugin) Option
func WithPoolSize ¶
func WithProtocol ¶
func WithRandomBalance ¶
func WithRandomBalance() Option
func WithRandomSelector ¶
func WithRandomSelector() Option
func WithResolver ¶
func WithRoundRobinBalance ¶
func WithRoundRobinBalance() Option
func WithStackTrace ¶
func WithStackTrace() Option
func WithTlsClient ¶
func WithTraitMessageParser ¶
func WithTraitMessageParser() Option