hbctrl

package
v3.0.0-rc67 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package hbctrl manage data and status of daemon heartbeats

It maintains the local node heartbeats status cache, this cache is published to daemondata on a ticker interval

Example:

c := New()
c.Start(context.Background())

// from another hb#2.tx routine
// Add a watchers for hb#2.rx nodes node2 and node3
// watchers are responsible for firing hb_stale/hb_beating event to
// controller for hbID + remote nodename
cmdC <- hbctrl.CmdAddWatcher{
	HbID:     "hb#2.tx",
	Nodename: "node2",
	Ctx:      ctx,
	Timeout:  r.timeout,
}
cmdC <- hbctrl.CmdAddWatcher{
	HbID:     "hb#2.tx",
	Nodename: "node3",
	Ctx:      ctx,
	Timeout:  r.timeout,
}

//set the success status of node2
c.cmdC() <- hbctrl.CmdSetPeerSuccess{
	Nodename: "node2",
	HbID:     "hb#2.tx",
	Success:  true,
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type C

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

C struct holds the hb controller data

func New

func New() *C

func (*C) Start

func (c *C) Start(ctx context.Context) chan<- any

Start starts hb controller goroutine, it returns its cmd chan

The hb controller is responsible if the heartbeat data cache from: - register/unregister heartbeat tx or rx - addWatcher/delWatcher of a hb peer - setPeerSuccess

The cache is sent to daemondata on regular time interval

The controller will die when ctx is done

func (*C) Stop

func (c *C) Stop() error

type CmdAddWatcher

type CmdAddWatcher struct {
	HbID     string
	Nodename string
	Desc     string
	Ctx      context.Context
	Timeout  time.Duration
}

CmdAddWatcher is a command to run new instance of a hb watcher for a remote

type CmdDelWatcher

type CmdDelWatcher struct {
	HbID     string
	Nodename string
}

CmdDelWatcher is a command to stop one instance of a hb watcher for a remote

type CmdEvent

type CmdEvent struct {
	Name     string
	Nodename string
	HbID     string
	// contains filtered or unexported fields
}

CmdEvent is a command to post new hb event

type CmdGetEventStats

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

CmdGetEventStats is a getter of ctrl event counters

type CmdRegister

type CmdRegister struct {
	ID string // the new hb id (example: hb#1.tx)
	// Type is the hb type
	Type string
}

CmdRegister is the command to register a new heartbeat status

type CmdSetAlert

type CmdSetAlert struct {
	HbID  string
	Alert []daemonsubsystem.Alert
}

CmdSetAlert is a command to post new hb alert

type CmdSetDesc

type CmdSetDesc struct {
	HbID     string
	Nodename string
	Desc     string
}

CmdSetDesc is a command to set the description of the peer of a hb stream, as the slot a disk stream writes or reads, which the stream knows once claimed or read, after it added its watchers.

type CmdSetPeerStatus

type CmdSetPeerStatus struct {
	Nodename   string
	HbID       string
	PeerStatus daemonsubsystem.HeartbeatStreamPeerStatus
}

CmdSetPeerStatus is a command to set a hb peer HeartbeatPeerStatus for a node

type CmdSetPeerSuccess

type CmdSetPeerSuccess struct {
	Nodename string
	HbID     string
	Success  bool
}

CmdSetPeerSuccess is a command to set a hb peer success value for a node

type CmdSetState

type CmdSetState struct {
	ID    string
	State string
}

CmdSetState is the command to update a heartbeat status state

type CmdUnregister

type CmdUnregister struct {
	ID string // the hb id to remove (example: hb#1.tx)
}

CmdUnregister is the command to unregister a heartbeat status

type DecodeErrors

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

DecodeErrors logs the heartbeat messages of a peer this agent can not decode, once per peer and error rather than once per message.

A peer whose message decrypts is alive, whatever its message holds, and is counted so: a message this agent can not decode is one from a peer running another version, and finding that peer dead would have this node take over what it runs. Its data is not applied, which is what the log says, once, and again when it decodes again.

func (*DecodeErrors) Failed

func (t *DecodeErrors) Failed(log *plog.Logger, node string, err error)

Failed logs a message of node this agent could not decode, when the error is not the one it logged last for that node.

func (*DecodeErrors) Succeeded

func (t *DecodeErrors) Succeeded(log *plog.Logger, node string)

Succeeded notes a message of node this agent decoded, and logs the recovery of a node whose messages it could not decode.

type EventStats

type EventStats map[string]int

EventStats is a map that holds event counters

type GetPeerStatus

type GetPeerStatus struct {
	HbID string
	// contains filtered or unexported fields
}

GetPeerStatus is command to retrieve remote peer status for a hb

type RemoteBeating

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

RemoteBeating holds Remote beating stats for a remote node

Jump to

Keyboard shortcuts

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