daemondata

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: 42 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 daemondata implements daemon journaled data

import "opensvc.com/opensvc/daemon/daemondata" cmdC, cancel := daemondata.Start(context.Background()) defer cancel() dataBus := daemondata.New(cmdC)

status := dataBus.ClusterData() // retrieve daemon data bus.ApplyFull("remote-1", remoteNodeStatus) bus.ApplyPatch("remote-1", patchMsg) bus.CommitPending(context.Background()) status = bus.ClusterData() localNodeStatus := bus.GetLocalNodeStatus()

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDrained = errors.New("drained command")
)

Functions

func BusFromContext

func BusFromContext(ctx context.Context) chan<- Caller

BusFromContext function returns the command chan stored in the context

func ContextWithBus

func ContextWithBus(parent context.Context, cmd chan<- Caller) context.Context

ContextWithBus function returns copy of parent, including the daemon data command chan.

func PropagationInterval

func PropagationInterval() time.Duration

func Start

func Start(parent context.Context, drainDuration time.Duration, subQS pubsub.QueueSizer) (chan<- Caller, chan<- *hbtype.Msg, context.CancelFunc)

Start runs the daemon journaled data manager

It returns a cmdC chan to submit actions on cluster data

Types

type Caller

type Caller interface {
	SetError(error)
	// contains filtered or unexported methods
}

Caller defines interface to implement for daemondata loop cmd processing the function will hold the daemondata loop while running

err := Caller.call(ctx, d)
Caller.SetError(err)

type HbMessageType

type HbMessageType struct {
	Type        string
	Nodes       []string
	JoinedNodes []string
	Gens        node.Gen
}

type T

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

T struct holds a daemondata manager cmdC to submit orders

func FromContext

func FromContext(ctx context.Context) *T

func New

func New(cmd chan<- Caller) *T

New returns a new *T from an existing daemondata manager

func (T) ClusterData

func (t T) ClusterData() *clusterdump.Data

ClusterData returns deep copy of status

func (T) ClusterDataAfterPublished

func (t T) ClusterDataAfterPublished(publisher pubsub.Publisher, timeout time.Duration) (*clusterdump.Data, bool)

ClusterDataAfterPublished returns a deep copy of the cluster data once the manager processed every message published before this call, and false when the manager did not answer within timeout.

ClusterData answers from the commands channel, which the manager serves apart from its subscription: a message published, but still queued on the subscription, is not in the copy. A caller subscribing to the bus, then replaying the cluster data before forwarding what its subscription receives, would never see such a message. The request goes through the bus instead, queued after the messages published before it.

The bus returns from a publication once it queued it on every matching subscription and waits while one of them is full: a manager stalled on its subscription would hold the request, and the caller, past timeout. The request is published apart, the timeout running from the call; its reply channel is buffered, the manager never waits on a caller that gave up.

func (T) ClusterDataJSON

func (t T) ClusterDataJSON() ([]byte, error)

ClusterDataJSON returns the cluster dataset already marshalled.

The callers that put the dataset on the wire, the collector feed and GET /daemon/status, were each paying three serializations of it: the marshal and the unmarshal of the deep copy, and then their own marshal of what came back. Marshalling on the daemondata goroutine, where the dataset cannot change under it, is one, and it needs no copy at all: what comes back is bytes, which no caller can modify and every caller can share.

It stays behind the same singleflight. Sharing was what made sharing the struct wrong; sharing bytes is only ever right.

func (T) ClusterNodeData

func (t T) ClusterNodeData(n string) *node.Node

ClusterNodeData returns deep copy of cluster node data for node n. It returns nil when node n is not found in cluster data.

func (T) DaemonRefresh

func (t T) DaemonRefresh()

DaemonRefresh updates the private dataset of a daemon subsystem (scheduler, dns, ...)

func (T) DropPeerNode

func (t T) DropPeerNode(peerNode string) error

DropPeerNode is a public method to drop peer node from t. It uses private call to func (d *data) dropPeer. It is used by a node stale detector to call drop peer on stale <peer> detection.

func (T) GetHbMessageType

func (t T) GetHbMessageType() HbMessageType

GetHbMessageType returns either "undef", "ping", "full" or "patch" Used by nmon start up to determine if rejoin can be skipped.

func (T) SetHBSendQ

func (t T) SetHBSendQ(hbSendQ chan<- hbtype.Msg) error

SetHBSendQ defines daemondata hbSendQ. The hbSendQ is used during queueNewHbMsg to push heartbeat message to this queue, see usage example for hb msgToTx multiplexer Example:

msgC := make(chan hbtype.Msg)
SetHBSendQ(msgC) // inform daemondata we are listening on this queue
defer SetHBSendQ(nil) // inform daemondata, we are not anymore reading on this queue
for {
   select {
   case msg := <- msgC:
      ...
   case <-ctx.Done():
      return
   }
}

Jump to

Keyboard shortcuts

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