Documentation
¶
Index ¶
- Variables
- func Decode(rsp netx.Response, msg interface{}) error
- func NewRequest(ctype netx.CodecType, msg interface{}) (netx.Request, error)
- type CallOption
- type CallOptions
- type Caller
- type Client
- type Configer
- type ConnPool
- type Future
- type Interceptor
- type Option
- func WithBalancer(b loadbalance.Balancer) Option
- func WithConfig(v Configer) Option
- func WithConnPool(p ConnPool) Option
- func WithFailover(v int) Option
- func WithFilter(v loadbalance.Filter) Option
- func WithProtocol(p netx.Protocol) Option
- func WithProxy(p string) Option
- func WithResolver(r discovery.Resolver) Option
- func WithTran(t netx.Tran) Option
- type Options
- type RetryPolicy
- type Retryer
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoInstances = errors.New("no instances") ErrInvalidCallback = errors.New("invalid callback") )
some error
Functions ¶
Types ¶
type CallOptions ¶
type CallOptions struct {
DialTimeout time.Duration //
CallTimeout time.Duration //
Callback interface{} // 异步回调函数
RetryPolicy RetryPolicy // 重试策略
}
CallOptions Call时可选参数
type Caller ¶
type Caller interface {
Register(req netx.Request, callback netx.Callback, timeout time.Duration, retryer Retryer) error
Unregister(seqId uint32)
// Find 查询Callback,会自动注销
Find(packet netx.Packet) netx.Callback
}
Caller 用于跟踪异步回调和超时处理
type Client ¶
type Client interface {
Call(ctx context.Context, req netx.Request, opts ...CallOption) (netx.Response, error)
Close() error
}
Client .
type Configer ¶
type Configer interface {
GetDialTimeout(ctx context.Context, req netx.Request) time.Duration
GetCallTimeout(ctx context.Context, req netx.Request) time.Duration
}
Configer 配置参数,可实现此接口从配置控制面获取相关配置
type Future ¶
type Future interface {
Add()
Done(rsp netx.Response, err error)
Wait() (netx.Response, error)
Recycle()
}
Future 用于获取异步结果
type Interceptor ¶
type Option ¶
type Option func(*Options)
func WithBalancer ¶
func WithBalancer(b loadbalance.Balancer) Option
func WithConfig ¶
func WithConnPool ¶
func WithFailover ¶
func WithFilter ¶
func WithFilter(v loadbalance.Filter) Option
func WithProtocol ¶
func WithResolver ¶
type Options ¶
type Options struct {
Tran netx.Tran //
Protocol netx.Protocol // 默认编码协议
Resolver discovery.Resolver //
Balancer loadbalance.Balancer //
Filter loadbalance.Filter // 用于过滤
Config Configer // 配置信息
Proxy string // 代理服务名
Failover int // 故障转移次数
ConnPool ConnPool //
// contains filtered or unexported fields
}
Options 可选配置信息
type RetryPolicy ¶
RetryPolicy 重试策略,比如基于次数
Source Files
¶
Click to show internal directories.
Click to hide internal directories.