healthcheck

package
v1.17.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 25 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultShardSize uint32

Functions

func Initialize

func Initialize(ctx context.Context, hcOpt *Config, cacheOpen bool, bc *batch.Controller) error

Initialize 初始化

func SetServer added in v1.14.2

func SetServer(srv *Server)

SetServer for test only

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) 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 *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 健康检查配置

func (*Config) SetDefault

func (c *Config) SetDefault()

SetDefault 设置默认值

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 GetServer

func GetServer() (*Server, error)

GetServer 获取已经初始化好的Server

func TestInitialize

func TestInitialize(ctx context.Context, hcOpt *Config, cacheOpen bool, bc *batch.Controller,
	storage store.Store) (*Server, error)

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) Destroy added in v1.17.3

func (s *Server) Destroy()

func (*Server) GetLastHeartbeat

func (s *Server) GetLastHeartbeat(req *apiservice.Instance) *apiservice.Response

GetLastHeartbeat 获取上一次心跳的时间

func (*Server) ListCheckerServer added in v1.14.0

func (s *Server) ListCheckerServer() []*model.Instance

ListCheckerServer get checker server instance list

func (*Server) RecordHistory

func (s *Server) RecordHistory(entry *model.RecordEntry)

RecordHistory server对外提供history插件的简单封装

func (*Server) Report

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL