Documentation ¶
Index ¶
- Variables
- func SendClientReply(futures interface{}, code uint32, result error)
- func StoreCode2APICode(err error) uint32
- type ClientCtrl
- type ClientFuture
- type Config
- type Controller
- func (bc *Controller) AsyncCreateInstance(svcId string, instance *api.Instance, needWait bool) *InstanceFuture
- func (bc *Controller) AsyncDeleteInstance(instance *api.Instance) *InstanceFuture
- func (bc *Controller) AsyncDeregisterClient(client *api.Client) *ClientFuture
- func (bc *Controller) AsyncHeartbeat(instance *api.Instance, healthy bool) *InstanceFuture
- func (bc *Controller) AsyncRegisterClient(client *api.Client) *ClientFuture
- func (bc *Controller) ClientDeregisterOpen() bool
- func (bc *Controller) ClientRegisterOpen() bool
- func (bc *Controller) CreateInstanceOpen() bool
- func (bc *Controller) DeleteInstanceOpen() bool
- func (bc *Controller) HeartbeatOpen() bool
- func (bc *Controller) Start(ctx context.Context)
- type CtrlConfig
- type InstanceCtrl
- func NewBatchDeregisterCtrl(storage store.Store, cacheMgn *cache.CacheManager, config *CtrlConfig) (*InstanceCtrl, error)
- func NewBatchHeartbeatCtrl(storage store.Store, cacheMgn *cache.CacheManager, config *CtrlConfig) (*InstanceCtrl, error)
- func NewBatchRegisterCtrl(storage store.Store, cacheMgn *cache.CacheManager, config *CtrlConfig) (*InstanceCtrl, error)
- type InstanceFuture
- func (future *InstanceFuture) CanDrop() bool
- func (future *InstanceFuture) Code() uint32
- func (future *InstanceFuture) Instance() *model.Instance
- func (future *InstanceFuture) Reply(cur time.Time, code uint32, result error)
- func (future *InstanceFuture) SetInstance(instance *model.Instance)
- func (future *InstanceFuture) Wait() error
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func SendClientReply ¶
SendReply 批量答复futures
func StoreCode2APICode ¶
StoreCode2APICode store code to api code
Types ¶
type ClientCtrl ¶
type ClientCtrl struct {
// contains filtered or unexported fields
}
InstanceCtrl 批量操作实例的类
func NewBatchDeregisterClientCtrl ¶
func NewBatchDeregisterClientCtrl(storage store.Store, config *CtrlConfig) (*ClientCtrl, error)
NewBatchDeregisterClientCtrl 注册客户端批量操作对象
func NewBatchRegisterClientCtrl ¶
func NewBatchRegisterClientCtrl(storage store.Store, config *CtrlConfig) (*ClientCtrl, error)
NewBatchRegisterClientCtrl 注册客户端批量操作对象
type ClientFuture ¶
type ClientFuture struct {
// contains filtered or unexported fields
}
InstanceFuture 创建实例的异步结构体
func (*ClientFuture) Client ¶
func (future *ClientFuture) Client() *model.Client
Client 获取 client 信息
func (*ClientFuture) Reply ¶
func (future *ClientFuture) Reply(code uint32, result error)
Reply future的应答
func (*ClientFuture) SetClient ¶
func (future *ClientFuture) SetClient(client *model.Client)
SetClient 设置 client 信息
type Config ¶
type Config struct { Register *CtrlConfig `mapstructure:"register"` Deregister *CtrlConfig `mapstructure:"deregister"` Heartbeat *CtrlConfig `mapstructure:"heartbeat"` ClientRegister *CtrlConfig `mapstructure:"clientRegister"` ClientDeregister *CtrlConfig `mapstructure:"clientDeregister"` }
Config 批量配置,控制最大的条目,批量等待时间等
func ParseBatchConfig ¶
ParseBatchConfig 解析配置文件为config
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller 批量控制器
func NewBatchCtrlWithConfig ¶
func NewBatchCtrlWithConfig(storage store.Store, cacheMgn *cache.CacheManager, config *Config) (*Controller, error)
NewBatchCtrlWithConfig 根据配置文件创建一个批量控制器
func (*Controller) AsyncCreateInstance ¶
func (bc *Controller) AsyncCreateInstance(svcId string, instance *api.Instance, needWait bool) *InstanceFuture
AsyncCreateInstance 异步创建实例,返回一个future,根据future获取创建结果
func (*Controller) AsyncDeleteInstance ¶
func (bc *Controller) AsyncDeleteInstance(instance *api.Instance) *InstanceFuture
AsyncDeleteInstance 异步合并反注册
func (*Controller) AsyncDeregisterClient ¶
func (bc *Controller) AsyncDeregisterClient(client *api.Client) *ClientFuture
AsyncDeregisterClient 异步合并反注册
func (*Controller) AsyncHeartbeat ¶
func (bc *Controller) AsyncHeartbeat(instance *api.Instance, healthy bool) *InstanceFuture
AsyncHeartbeat 异步心跳
func (*Controller) AsyncRegisterClient ¶
func (bc *Controller) AsyncRegisterClient(client *api.Client) *ClientFuture
AsyncRegisterClient 异步合并反注册
func (*Controller) ClientDeregisterOpen ¶
func (bc *Controller) ClientDeregisterOpen() bool
ClientDeregisterOpen 删除客户端是否开启
func (*Controller) ClientRegisterOpen ¶
func (bc *Controller) ClientRegisterOpen() bool
ClientRegisterOpen 添加客户端是否开启
func (*Controller) CreateInstanceOpen ¶
func (bc *Controller) CreateInstanceOpen() bool
CreateInstanceOpen 创建是否开启
func (*Controller) DeleteInstanceOpen ¶
func (bc *Controller) DeleteInstanceOpen() bool
DeleteInstanceOpen 删除实例是否开启
func (*Controller) Start ¶
func (bc *Controller) Start(ctx context.Context)
Start 开启批量控制器 启动多个协程,接受外部create/delete请求
type CtrlConfig ¶
type CtrlConfig struct { // 是否开启Batch工作模式 Open bool `mapstructure:"open"` // 注册请求队列的长度 QueueSize int `mapstructure:"queueSize"` // 最长多久一次批量操作 WaitTime string `mapstructure:"waitTime"` // 每次操作最大的批量数 MaxBatchCount int `mapstructure:"maxBatchCount"` // 写store的并发协程数 Concurrency int `mapstructure:"concurrency"` // 任务最大存活周期 TaskLife string `mapstructure:"taskLife"` }
CtrlConfig batch控制配置项
type InstanceCtrl ¶
type InstanceCtrl struct {
// contains filtered or unexported fields
}
InstanceCtrl 批量操作实例的类
func NewBatchDeregisterCtrl ¶
func NewBatchDeregisterCtrl(storage store.Store, cacheMgn *cache.CacheManager, config *CtrlConfig) ( *InstanceCtrl, error)
NewBatchDeregisterCtrl 实例反注册的操作对象
func NewBatchHeartbeatCtrl ¶
func NewBatchHeartbeatCtrl(storage store.Store, cacheMgn *cache.CacheManager, config *CtrlConfig) ( *InstanceCtrl, error)
NewBatchHeartbeatCtrl 实例心跳的操作对象
func NewBatchRegisterCtrl ¶
func NewBatchRegisterCtrl(storage store.Store, cacheMgn *cache.CacheManager, config *CtrlConfig) (*InstanceCtrl, error)
NewBatchRegisterCtrl 注册实例批量操作对象
func (*InstanceCtrl) Start ¶
func (ctrl *InstanceCtrl) Start(ctx context.Context)
Start 开始启动批量操作实例的相关协程
type InstanceFuture ¶
type InstanceFuture struct {
// contains filtered or unexported fields
}
InstanceFuture 创建实例的异步结构体
func (*InstanceFuture) CanDrop ¶
func (future *InstanceFuture) CanDrop() bool
CanDrop 该 future 是否可以丢弃
func (*InstanceFuture) Instance ¶
func (future *InstanceFuture) Instance() *model.Instance
Instance 获取ins
func (*InstanceFuture) Reply ¶
func (future *InstanceFuture) Reply(cur time.Time, code uint32, result error)
Reply future的应答
func (*InstanceFuture) SetInstance ¶
func (future *InstanceFuture) SetInstance(instance *model.Instance)
SetInstance 设置ins