Documentation ¶
Index ¶
- Variables
- func Initialize(ctx context.Context, hcOpt *Config, cacheOpen bool, bc *batch.Controller) error
- func NewShardMap(size uint32) *shardMap
- type AdoptEvent
- type Bucket
- type CacheEvent
- type CacheProvider
- func (c *CacheProvider) GetClient(clientId string) *model.Client
- func (c *CacheProvider) GetInstance(instanceId string) *model.Instance
- func (c *CacheProvider) OnBatchCreated(value interface{})
- func (c *CacheProvider) OnBatchDeleted(value interface{})
- func (c *CacheProvider) OnBatchUpdated(value interface{})
- func (c *CacheProvider) OnCreated(value interface{})
- func (c *CacheProvider) OnDeleted(value interface{})
- func (c *CacheProvider) OnUpdated(value interface{})
- func (c *CacheProvider) RangeHealthCheckClients(check func(itemChecker ItemWithChecker, client *model.Client))
- func (c *CacheProvider) RangeHealthCheckInstances(check func(itemChecker ItemWithChecker, ins *model.Instance))
- func (c *CacheProvider) RangeSelfServiceInstances(check func(instance *api.Instance))
- type CheckScheduler
- func (c *CheckScheduler) AddClient(clientWithChecker *ClientWithChecker)
- func (c *CheckScheduler) AddInstance(instanceWithChecker *InstanceWithChecker)
- func (c *CheckScheduler) DelClient(clientWithChecker *ClientWithChecker)
- func (c *CheckScheduler) DelInstance(instanceWithChecker *InstanceWithChecker)
- type ClientWithChecker
- type Config
- type Continuum
- type Dispatcher
- type InstanceWithChecker
- type ItemType
- type ItemWithChecker
- type Server
- func (s *Server) CacheProvider() (*CacheProvider, error)
- func (s *Server) GetLastHeartbeat(req *api.Instance) *api.Response
- func (s *Server) RecordHistory(entry *model.RecordEntry)
- func (s *Server) Report(ctx context.Context, req *api.Instance) *api.Response
- func (s *Server) ReportByClient(ctx context.Context, req *api.Client) *api.Response
- func (s *Server) SetInstanceCache(instanceCache cache.InstanceCache)
- func (s *Server) SetServiceCache(serviceCache cache.ServiceCache)
- type TimeAdjuster
Constants ¶
This section is empty.
Variables ¶
var DefaultShardSize uint32
Functions ¶
func Initialize ¶
Initialize 初始化
func NewShardMap ¶
func NewShardMap(size uint32) *shardMap
NewShardMap creates a new shardMap and init shardSize.
Types ¶
type AdoptEvent ¶
type AdoptEvent struct { InstanceId string Add bool Checker plugin.HealthChecker }
AdoptEvent is the event for adopt
type CacheEvent ¶
type CacheEvent struct {
// contains filtered or unexported fields
}
CacheEvent provides the event for cache changes
type CacheProvider ¶
type CacheProvider struct {
// contains filtered or unexported fields
}
CacheProvider provider health check objects for service cache
func (*CacheProvider) GetClient ¶
func (c *CacheProvider) GetClient(clientId string) *model.Client
GetInstance get instance by id
func (*CacheProvider) GetInstance ¶
func (c *CacheProvider) GetInstance(instanceId string) *model.Instance
GetInstance get instance by id
func (*CacheProvider) OnBatchCreated ¶
func (c *CacheProvider) OnBatchCreated(value interface{})
OnBatchCreated callback when cache value created
func (*CacheProvider) OnBatchDeleted ¶
func (c *CacheProvider) OnBatchDeleted(value interface{})
OnBatchDeleted callback when cache value deleted
func (*CacheProvider) OnBatchUpdated ¶
func (c *CacheProvider) OnBatchUpdated(value interface{})
OnBatchUpdated callback when cache value updated
func (*CacheProvider) OnCreated ¶
func (c *CacheProvider) OnCreated(value interface{})
OnCreated callback when cache value created
func (*CacheProvider) OnDeleted ¶
func (c *CacheProvider) OnDeleted(value interface{})
OnDeleted callback when cache value deleted
func (*CacheProvider) OnUpdated ¶
func (c *CacheProvider) OnUpdated(value interface{})
OnUpdated callback when cache value updated
func (*CacheProvider) RangeHealthCheckClients ¶
func (c *CacheProvider) RangeHealthCheckClients(check func(itemChecker ItemWithChecker, client *model.Client))
RangeHealthCheckClients range loop values
func (*CacheProvider) RangeHealthCheckInstances ¶
func (c *CacheProvider) RangeHealthCheckInstances(check func(itemChecker ItemWithChecker, ins *model.Instance))
RangeHealthCheckInstances range loop values
func (*CacheProvider) RangeSelfServiceInstances ¶
func (c *CacheProvider) RangeSelfServiceInstances(check func(instance *api.Instance))
RangeSelfServiceInstances range loop selfServiceInstances
type CheckScheduler ¶
type CheckScheduler struct {
// contains filtered or unexported fields
}
CheckScheduler schedule and run check actions
func (*CheckScheduler) AddClient ¶
func (c *CheckScheduler) AddClient(clientWithChecker *ClientWithChecker)
AddInstance add instance to check
func (*CheckScheduler) AddInstance ¶
func (c *CheckScheduler) AddInstance(instanceWithChecker *InstanceWithChecker)
AddInstance add instance to check
func (*CheckScheduler) DelClient ¶
func (c *CheckScheduler) DelClient(clientWithChecker *ClientWithChecker)
DelInstance del instance from check
func (*CheckScheduler) DelInstance ¶
func (c *CheckScheduler) DelInstance(instanceWithChecker *InstanceWithChecker)
DelInstance del instance from check
type ClientWithChecker ¶
type ClientWithChecker struct {
// contains filtered or unexported fields
}
ClientWithChecker instance and checker combine
func (*ClientWithChecker) GetChecker ¶
func (ic *ClientWithChecker) GetChecker() plugin.HealthChecker
GetChecker 获取对应的 checker 对象
func (*ClientWithChecker) GetClient ¶
func (ic *ClientWithChecker) GetClient() *model.Client
GetClient 获取上报客户端信息
func (*ClientWithChecker) GetHashValue ¶
func (ic *ClientWithChecker) GetHashValue() uint
GetHashValue 获取 hashvalue 信息
func (*ClientWithChecker) GetInstance ¶
func (ic *ClientWithChecker) GetInstance() *model.Instance
GetInstance 获取服务实例
type Config ¶
type Config struct { Open bool `yaml:"open"` Service string `yaml:"service"` SlotNum int `yaml:"slotNum"` LocalHost string `yaml:"localHost"` MinCheckInterval time.Duration `yaml:"minCheckInterval"` MaxCheckInterval time.Duration `yaml:"maxCheckInterval"` ClientReportInterval time.Duration `yaml:"clientReportInterval"` Checkers []plugin.ConfigEntry `yaml:"checkers"` Batch map[string]interface{} `yaml:"batch"` }
Config 健康检查配置
type Continuum ¶
type Continuum struct {
// contains filtered or unexported fields
}
Continuum consistent hash ring
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher dispatch all instances using consistent hash ring
func (*Dispatcher) UpdateStatusByEvent ¶
func (d *Dispatcher) UpdateStatusByEvent(event CacheEvent)
UpdateStatusByEvent 更新变更状态
type InstanceWithChecker ¶
type InstanceWithChecker struct {
// contains filtered or unexported fields
}
InstanceWithChecker instance and checker combine
func (*InstanceWithChecker) GetChecker ¶
func (ic *InstanceWithChecker) GetChecker() plugin.HealthChecker
GetChecker 获取对应的 checker 对象
func (*InstanceWithChecker) GetClient ¶
func (ic *InstanceWithChecker) GetClient() *model.Client
GetClient 获取上报客户端信息
func (*InstanceWithChecker) GetHashValue ¶
func (ic *InstanceWithChecker) GetHashValue() uint
GetHashValue 获取 hashvalue 信息
func (*InstanceWithChecker) GetInstance ¶
func (ic *InstanceWithChecker) GetInstance() *model.Instance
GetInstance 获取服务实例
type ItemWithChecker ¶
type ItemWithChecker interface { // GetInstance 获取服务实例 GetInstance() *model.Instance // GetClient 获取上报客户端信息 GetClient() *model.Client // GetChecker 获取对应的 checker 对象 GetChecker() plugin.HealthChecker // GetHashValue 获取 hashvalue 信息 GetHashValue() uint }
ItemWithChecker item and checker combine GetInstance 与 GetClient 互斥
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server health checks the main server
func TestInitialize ¶
func (*Server) CacheProvider ¶
func (s *Server) CacheProvider() (*CacheProvider, error)
CacheProvider get cache provider
func (*Server) GetLastHeartbeat ¶
GetLastHeartbeat 获取上一次心跳的时间
func (*Server) RecordHistory ¶
func (s *Server) RecordHistory(entry *model.RecordEntry)
RecordHistory server对外提供history插件的简单封装
func (*Server) ReportByClient ¶
ReportByClient report heartbeat request by client
func (*Server) SetInstanceCache ¶
func (s *Server) SetInstanceCache(instanceCache cache.InstanceCache)
SetInstanceCache 设置服务实例缓存
func (*Server) SetServiceCache ¶
func (s *Server) SetServiceCache(serviceCache cache.ServiceCache)
SetServiceCache 设置服务缓存
type TimeAdjuster ¶
type TimeAdjuster struct {
// contains filtered or unexported fields
}
TimeAdjuster adjust the seconds from databases
func (*TimeAdjuster) GetDiff ¶
func (t *TimeAdjuster) GetDiff() int64
GetDiff get diff time between store and current PC