Documentation ¶
Index ¶
- Variables
- func Initialize(ctx context.Context, hcOpt *Config, bc *batch.Controller) error
- func SerialSetInsDbStatus(svr *Server, ins *apiservice.Instance, healthStatus bool, lastBeatTime int64) apimodel.Code
- func SetServer(srv *Server)
- func WithBatchController(ba *batch.Controller) serverOption
- func WithCache(cacheMgr cache.CacheManager) serverOption
- func WithPlugins() serverOption
- func WithStore(s store.Store) serverOption
- func WithTimeAdjuster(adjuster *TimeAdjuster) serverOption
- type AdoptEvent
- type CacheEvent
- type CacheProvider
- func (c *CacheProvider) GetClient(clientId string) *model.Client
- func (c *CacheProvider) GetInstance(instanceId string) *model.Instance
- func (c *CacheProvider) GetSelfServiceInstance(instanceId string) *model.Instance
- 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 *apiservice.Instance))
- type CheckScheduler
- func (c *CheckScheduler) AddClient(clientWithChecker *ClientWithChecker)
- func (c *CheckScheduler) DelClient(clientWithChecker *ClientWithChecker)
- func (c *CheckScheduler) DelInstance(instanceWithChecker *InstanceWithChecker)
- func (c *CheckScheduler) UpsertInstance(instanceWithChecker *InstanceWithChecker)
- type ClientWithChecker
- type Config
- type Dispatcher
- type InstanceEventHealthCheckHandler
- type InstanceWithChecker
- type ItemWithChecker
- type LeaderChangeEventHandler
- type Server
- func (s *Server) CacheProvider() (*CacheProvider, error)
- func (s *Server) Checkers() map[int32]plugin.HealthChecker
- func (s *Server) Destroy()
- func (s *Server) GetLastHeartbeat(req *apiservice.Instance) *apiservice.Response
- func (s *Server) ListCheckerServer() []*model.Instance
- func (s *Server) RecordHistory(entry *model.RecordEntry)
- func (s *Server) Report(ctx context.Context, req *apiservice.Instance) *apiservice.Response
- func (s *Server) ReportByClient(ctx context.Context, req *apiservice.Client) *apiservice.Response
- func (s *Server) Reports(ctx context.Context, req []*apiservice.InstanceHeartbeat) *apiservice.Response
- func (s *Server) SelfService() string
- func (s *Server) SetInstanceCache(instanceCache cachetypes.InstanceCache)
- func (s *Server) SetServiceCache(serviceCache cachetypes.ServiceCache)
- type TimeAdjuster
Constants ¶
This section is empty.
Variables ¶
var DefaultShardSize uint32
Functions ¶
func Initialize ¶
Initialize 初始化
func SerialSetInsDbStatus ¶ added in v1.18.0
func WithBatchController ¶ added in v1.18.0
func WithBatchController(ba *batch.Controller) serverOption
WithBatchController .
func WithCache ¶ added in v1.18.0
func WithCache(cacheMgr cache.CacheManager) serverOption
WithCache .
func WithTimeAdjuster ¶ added in v1.18.0
func WithTimeAdjuster(adjuster *TimeAdjuster) serverOption
WithTimeAdjuster .
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) GetSelfServiceInstance ¶ added in v1.14.0
func (c *CacheProvider) GetSelfServiceInstance(instanceId string) *model.Instance
GetSelfServiceInstance get self service instance by id
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 *apiservice.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)
AddClient add client to check
func (*CheckScheduler) DelClient ¶
func (c *CheckScheduler) DelClient(clientWithChecker *ClientWithChecker)
DelClient del client from check
func (*CheckScheduler) DelInstance ¶
func (c *CheckScheduler) DelInstance(instanceWithChecker *InstanceWithChecker)
DelInstance del instance from check
func (*CheckScheduler) UpsertInstance ¶ added in v1.17.0
func (c *CheckScheduler) UpsertInstance(instanceWithChecker *InstanceWithChecker)
UpsertInstance insert or update instance to 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"` ClientCheckInterval time.Duration `yaml:"clientCheckInterval"` ClientCheckTtl time.Duration `yaml:"clientCheckTtl"` Checkers []plugin.ConfigEntry `yaml:"checkers"` Batch map[string]interface{} `yaml:"batch"` }
Config 健康检查配置
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 InstanceEventHealthCheckHandler ¶ added in v1.15.0
type InstanceEventHealthCheckHandler struct {
// contains filtered or unexported fields
}
func (*InstanceEventHealthCheckHandler) OnEvent ¶ added in v1.15.0
func (handler *InstanceEventHealthCheckHandler) OnEvent(ctx context.Context, i interface{}) error
OnEvent event trigger
func (*InstanceEventHealthCheckHandler) PreProcess ¶ added in v1.15.0
func (handler *InstanceEventHealthCheckHandler) PreProcess(ctx context.Context, value any) any
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 LeaderChangeEventHandler ¶ added in v1.14.2
type LeaderChangeEventHandler struct {
// contains filtered or unexported fields
}
LeaderChangeEventHandler process the event when server act as leader
func (*LeaderChangeEventHandler) OnEvent ¶ added in v1.15.0
func (handler *LeaderChangeEventHandler) OnEvent(ctx context.Context, i interface{}) error
OnEvent event trigger
func (*LeaderChangeEventHandler) PreProcess ¶ added in v1.15.0
func (handler *LeaderChangeEventHandler) PreProcess(ctx context.Context, value any) any
PreProcess do preprocess logic for event
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server health checks the main server
func NewHealthServer ¶ added in v1.18.0
func TestInitialize ¶
func (*Server) CacheProvider ¶
func (s *Server) CacheProvider() (*CacheProvider, error)
CacheProvider get cache provider
func (*Server) Checkers ¶ added in v1.15.2
func (s *Server) Checkers() map[int32]plugin.HealthChecker
Checkers get all health checker, for test only
func (*Server) GetLastHeartbeat ¶
func (s *Server) GetLastHeartbeat(req *apiservice.Instance) *apiservice.Response
GetLastHeartbeat 获取上一次心跳的时间
func (*Server) ListCheckerServer ¶ added in v1.14.0
ListCheckerServer get checker server instance list
func (*Server) RecordHistory ¶
func (s *Server) RecordHistory(entry *model.RecordEntry)
RecordHistory server对外提供history插件的简单封装
func (*Server) Report ¶
func (s *Server) Report(ctx context.Context, req *apiservice.Instance) *apiservice.Response
Report heartbeat request
func (*Server) ReportByClient ¶
func (s *Server) ReportByClient(ctx context.Context, req *apiservice.Client) *apiservice.Response
ReportByClient report heartbeat request by client
func (*Server) Reports ¶ added in v1.17.0
func (s *Server) Reports(ctx context.Context, req []*apiservice.InstanceHeartbeat) *apiservice.Response
Reports batch report heartbeat request
func (*Server) SetInstanceCache ¶
func (s *Server) SetInstanceCache(instanceCache cachetypes.InstanceCache)
SetInstanceCache 设置服务实例缓存
func (*Server) SetServiceCache ¶
func (s *Server) SetServiceCache(serviceCache cachetypes.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