healthcheck

package
v1.13.4 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 23 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 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 Bucket

type Bucket struct {
	Host   string
	Weight uint32
}

Bucket single bucket of hash ring

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

func (*Config) SetDefault

func (c *Config) SetDefault()

SetDefault 设置默认值

type Continuum

type Continuum struct {
	// contains filtered or unexported fields
}

Continuum consistent hash ring

func New

func New(buckets map[Bucket]bool) *Continuum

New hash ring

func (*Continuum) Hash

func (c *Continuum) Hash(h uint) string

Hash hash string to lookup node

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 ItemType

type ItemType int

func (ItemType) String

func (i ItemType) String() string

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 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) GetLastHeartbeat

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

GetLastHeartbeat 获取上一次心跳的时间

func (*Server) RecordHistory

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

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

func (*Server) Report

func (s *Server) Report(ctx context.Context, req *api.Instance) *api.Response

Report heartbeat request

func (*Server) ReportByClient

func (s *Server) ReportByClient(ctx context.Context, req *api.Client) *api.Response

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

Jump to

Keyboard shortcuts

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