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 ¶
- Variables
- func BusFromContext(ctx context.Context) chan<- Caller
- func ContextWithBus(parent context.Context, cmd chan<- Caller) context.Context
- func PropagationInterval() time.Duration
- func Start(parent context.Context, drainDuration time.Duration, subQS pubsub.QueueSizer) (chan<- Caller, chan<- *hbtype.Msg, context.CancelFunc)
- type Caller
- type HbMessageType
- type T
- func (t T) ClusterData() *clusterdump.Data
- func (t T) ClusterDataAfterPublished(publisher pubsub.Publisher, timeout time.Duration) (*clusterdump.Data, bool)
- func (t T) ClusterDataJSON() ([]byte, error)
- func (t T) ClusterNodeData(n string) *node.Node
- func (t T) DaemonRefresh()
- func (t T) DropPeerNode(peerNode string) error
- func (t T) GetHbMessageType() HbMessageType
- func (t T) SetHBSendQ(hbSendQ chan<- hbtype.Msg) error
Constants ¶
This section is empty.
Variables ¶
var (
ErrDrained = errors.New("drained command")
)
Functions ¶
func BusFromContext ¶
BusFromContext function returns the command chan stored in the context
func ContextWithBus ¶
ContextWithBus function returns copy of parent, including the daemon data command chan.
func PropagationInterval ¶
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 T ¶
type T struct {
// contains filtered or unexported fields
}
T struct holds a daemondata manager cmdC to submit orders
func FromContext ¶
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 ¶
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 ¶
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 ¶
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 ¶
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
}
}