heartbeat

package
v1.5.0-dev2 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HeartbeatMessageType is the message type for heartbeats
	HeartbeatMessageType = "heartbeat"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v1.4.0

type Client interface {
	SendHeartbeat(ctx context.Context, sequence uint64) error
}

type Heartbeat

type Heartbeat struct {
	NodeID   string
	Sequence uint64
}

Heartbeat represents a heartbeat message from a specific node. It contains the node ID and the sequence number of the heartbeat which is monotonically increasing (reboots aside). We do not use timestamps on the client, we rely solely on the server-side time to avoid clock drift issues.

type HeartbeatClient

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

func NewClient

func NewClient(nodeID string, publisher ncl.Publisher) *HeartbeatClient

func (*HeartbeatClient) SendHeartbeat

func (h *HeartbeatClient) SendHeartbeat(ctx context.Context, sequence uint64) error

type HeartbeatServer

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

func NewServer

func NewServer(params HeartbeatServerParams) (*HeartbeatServer, error)

func (*HeartbeatServer) CheckQueue

func (h *HeartbeatServer) CheckQueue(ctx context.Context)

CheckQueue will check the queue for old heartbeats that might make a node's liveness either unhealthy or unknown, and will update the node's status accordingly.

func (*HeartbeatServer) FilterNodeInfos

func (h *HeartbeatServer) FilterNodeInfos(nodeInfos []*models.NodeInfo, state models.NodeConnectionState) []*models.NodeInfo

FilterNodeInfos will return only those NodeInfos that have the requested liveness

func (*HeartbeatServer) HandleMessage added in v1.5.0

func (h *HeartbeatServer) HandleMessage(ctx context.Context, message *ncl.Message) error

func (*HeartbeatServer) RemoveNode

func (h *HeartbeatServer) RemoveNode(nodeID string)

RemoveNode will handle removing the liveness for a specific node. This is useful when a node is removed from the cluster.

func (*HeartbeatServer) ShouldProcess added in v1.5.0

func (h *HeartbeatServer) ShouldProcess(ctx context.Context, message *ncl.Message) bool

func (*HeartbeatServer) Start

func (h *HeartbeatServer) Start(ctx context.Context) error

func (*HeartbeatServer) UpdateNodeInfo

func (h *HeartbeatServer) UpdateNodeInfo(state *models.NodeState)

UpdateNode will add the liveness for specific nodes to their NodeInfo

type HeartbeatServerParams

type HeartbeatServerParams struct {
	Clock                 clock.Clock
	CheckFrequency        time.Duration
	NodeDisconnectedAfter time.Duration
}

type TimestampedHeartbeat

type TimestampedHeartbeat struct {
	Heartbeat
	Timestamp int64
}

Jump to

Keyboard shortcuts

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