nodecontrol

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package nodecontrol transports a small owner-authorized allowlist through shared storage. Bus messages are hints; only the exact target writes receipts.

Index

Constants

View Source
const Freshness = 30 * time.Second
View Source
const Topic = "nodecontrol.changed"

Variables

View Source
var ErrInvalid = errors.New("invalid request")
View Source
var ErrUnsupported = errors.New("unsupported setting")

Functions

This section is empty.

Types

type Capability

type Capability struct {
	Key       string `json:"key"`
	Scope     string `json:"scope"`
	Supported bool   `json:"supported"`
	Reason    string `json:"reason"`
}

type Control

type Control struct {
	NodeID           string       `json:"nodeId"`
	Boot             string       `json:"boot"`
	RequestedVersion int64        `json:"requestedVersion"`
	AppliedVersion   int64        `json:"appliedVersion"`
	State            string       `json:"state"`
	RequestID        string       `json:"requestId,omitempty"`
	ErrorCode        string       `json:"errorCode,omitempty"`
	UpdatedAt        time.Time    `json:"updatedAt"`
	Observed         Observed     `json:"observed"`
	Capabilities     []Capability `json:"capabilities"`
}

type Observed

type Observed struct {
	Weight   int  `json:"weight"`
	Draining bool `json:"draining"`
}

type Patch

type Patch struct {
	Weight   *int  `json:"weight,omitempty"`
	Draining *bool `json:"draining,omitempty"`
}

type Request

type Request struct {
	RequestID       string `json:"requestId"`
	Boot            string `json:"boot"`
	ExpectedVersion int64  `json:"expectedVersion"`
	Patch           Patch  `json:"patch"`
}

type Service

type Service struct {
	Store        *clusterconfig.NodeControls
	Bus          clusterbus.Bus
	NodeID, Boot string
	Target       Target
}

func (*Service) Get

func (s *Service) Get(ctx context.Context, node, boot string) (Control, error)

func (*Service) Run

func (s *Service) Run(ctx context.Context)

Run owns no detached work: callbacks only signal, and shutdown unsubscribes. Periodic reconciliation catches missed bus notifications. A new boot never consumes the previous boot's pending requests.

func (*Service) Submit

func (s *Service) Submit(ctx context.Context, node string, r Request) (Control, error)

type Target

type Target interface {
	Observe() (Observed, []Capability)
	Apply(context.Context, Patch) string
}

Jump to

Keyboard shortcuts

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