overlord

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Package overlord is the central control base, and ruler of all things.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockWorkshopBackend

func MockWorkshopBackend(b workshop.Backend) func()

Types

type Overlord

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

Overlord is the central manager of the system, keeping track of all available state managers and related helpers.

func Fake

func Fake() *Overlord

Fake creates an Overlord without any managers and with a backend not using disk. Managers can be added with AddManager. For testing.

func FakeWithState

func FakeWithState(handleRestart func(restart.RestartType)) *Overlord

FakeWithState creates an Overlord without any managers and with a backend not using disk. Managers can be added with AddManager. For testing.

func New

func New(dir string, restartHandler restart.Handler) (*Overlord, error)

New creates a new Overlord with all its state managers. It can be provided with an optional restart.Handler.

func (*Overlord) AddManager

func (o *Overlord) AddManager(mgr StateManager)

AddManager adds a manager to a fake overlord. It cannot be used for a normally initialized overlord those are already fully populated.

func (*Overlord) CanStandby

func (o *Overlord) CanStandby() bool

func (*Overlord) CommandManager

func (o *Overlord) CommandManager() *cmdstate.CommandManager

func (*Overlord) HookManager

func (o *Overlord) HookManager() *hookstate.HookManager

func (*Overlord) InterfaceManager

func (o *Overlord) InterfaceManager() *ifacestate.InterfaceManager

func (*Overlord) Loop

func (o *Overlord) Loop()

Loop runs a loop in a goroutine to ensure the current state regularly through StateEngine Ensure.

func (*Overlord) SdkManager

func (o *Overlord) SdkManager() *sdkstate.SdkManager

func (*Overlord) Settle

func (o *Overlord) Settle(timeout time.Duration) error

Settle runs first a state engine Ensure and then wait for activities to settle. That's done by waiting for all managers' activities to settle while making sure no immediate further Ensure is scheduled. It then waits similarly for all ready changes to reach the clean state. Chiefly for tests. Cannot be used in conjunction with Loop. If timeout is non-zero and settling takes longer than timeout, returns an error.

func (*Overlord) SettleObserveBeforeCleanups

func (o *Overlord) SettleObserveBeforeCleanups(timeout time.Duration, beforeCleanups func()) error

SettleObserveBeforeCleanups runs first a state engine Ensure and then wait for activities to settle. That's done by waiting for all managers' activities to settle while making sure no immediate further Ensure is scheduled. It then waits similarly for all ready changes to reach the clean state, but calls once the provided callback before doing that. Chiefly for tests. Cannot be used in conjunction with Loop. If timeout is non-zero and settling takes longer than timeout, returns an error.

func (*Overlord) StartOfOperationTime

func (m *Overlord) StartOfOperationTime() (time.Time, error)

StartOfOperationTime returns the time when workshop started operating, and sets it in the state when called for the first time.

func (*Overlord) StartUp

func (se *Overlord) StartUp() error

func (*Overlord) State

func (o *Overlord) State() *state.State

State returns the system state managed by the overlord.

func (*Overlord) StateEngine

func (o *Overlord) StateEngine() *StateEngine

StateEngine returns the state engine used by overlord.

func (*Overlord) Stop

func (o *Overlord) Stop() error

Stop stops the ensure loop and the managers under the StateEngine.

func (*Overlord) TaskRunner

func (o *Overlord) TaskRunner() *state.TaskRunner

TaskRunner returns the shared task runner responsible for running tasks for all managers under the overlord.

func (*Overlord) WorkshopBackend

func (o *Overlord) WorkshopBackend() workshop.Backend

func (*Overlord) WorkshopManager

func (o *Overlord) WorkshopManager() *workshopstate.WorkshopManager

type StateEngine

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

StateEngine controls the dispatching of state changes to state managers.

Most of the actual work performed by the state engine is in fact done by the individual managers registered. These managers must be able to cope with Ensure calls in any order, coordinating among themselves solely via the state.

func NewStateEngine

func NewStateEngine(s *state.State) *StateEngine

NewStateEngine returns a new state engine.

func (*StateEngine) AddManager

func (se *StateEngine) AddManager(m StateManager)

AddManager adds the provided manager to take part in state operations.

func (*StateEngine) Ensure

func (se *StateEngine) Ensure() error

Ensure asks every manager to ensure that they are doing the necessary work to put the current desired system state in place by calling their respective Ensure methods.

Managers must evaluate the desired state completely when they receive that request, and report whether they found any critical issues. They must not perform long running activities during that operation, though. These should be performed in properly tracked changes and tasks.

func (*StateEngine) StartUp

func (se *StateEngine) StartUp() error

StartUp asks all managers to perform any expensive initialization. It is a noop after the first invocation.

func (*StateEngine) State

func (se *StateEngine) State() *state.State

State returns the current system state.

func (*StateEngine) Stop

func (se *StateEngine) Stop()

Stop asks all managers to terminate activities running concurrently.

func (*StateEngine) Wait

func (se *StateEngine) Wait()

Wait waits for all managers current activities.

type StateManager

type StateManager interface {
	// Ensure forces a complete evaluation of the current state.
	// See StateEngine.Ensure for more details.
	Ensure() error
}

StateManager is implemented by types responsible for observing the system and manipulating it to reflect the desired state.

type StateStarterUp

type StateStarterUp interface {
	// StartUp asks manager to perform any expensive initialization.
	StartUp() error
}

StateStarterUp is optionally implemented by StateManager that have expensive initialization to perform before the main Overlord loop.

type StateStopper

type StateStopper interface {
	// Stop asks the manager to terminate all activities running
	// concurrently.  It must not return before these activities
	// are finished.
	Stop()
}

StateStopper is optionally implemented by StateManagers that have running activities that can be terminated.

type StateWaiter

type StateWaiter interface {
	// Wait asks manager to wait for all running activities to
	// finish.
	Wait()
}

StateWaiter is optionally implemented by StateManagers that have running activities that can be waited.

Directories

Path Synopsis
ctlcmd
Package ctlcmd contains the various workshopctl subcommands.
Package ctlcmd contains the various workshopctl subcommands.
schema
Package schema holds structs for reading and writing interface-related state data.
Package schema holds structs for reading and writing interface-related state data.
Package restart implements requesting restarts from any part of the code that has access to state.
Package restart implements requesting restarts from any part of the code that has access to state.
Package state implements the representation of system state.
Package state implements the representation of system state.

Jump to

Keyboard shortcuts

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