hbctrl

package
v0.0.0-...-0a8b275 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

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
	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
}

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