Documentation ¶
Overview ¶
Package overlord is the central control base, and ruler of all things.
Index ¶
- type Extension
- type Options
- type Overlord
- func (o *Overlord) AddManager(mgr StateManager)
- func (o *Overlord) CanStandby() bool
- func (o *Overlord) CheckManager() *checkstate.CheckManager
- func (o *Overlord) CommandManager() *cmdstate.CommandManager
- func (o *Overlord) Extension() Extension
- func (o *Overlord) Loop()
- func (o *Overlord) ServiceManager() *servstate.ServiceManager
- func (o *Overlord) Settle(timeout time.Duration) error
- func (o *Overlord) SettleObserveBeforeCleanups(timeout time.Duration, beforeCleanups func()) error
- func (m *Overlord) StartOfOperationTime() (time.Time, error)
- func (o *Overlord) StartUp() error
- func (o *Overlord) State() *state.State
- func (o *Overlord) StateEngine() *StateEngine
- func (o *Overlord) Stop() error
- func (o *Overlord) TaskRunner() *state.TaskRunner
- type StateEngine
- type StateManager
- type StateStarterUp
- type StateStopper
- type StateWaiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Extension ¶
type Extension interface { // ExtraManagers allows additional StateManagers to be used. ExtraManagers(o *Overlord) ([]StateManager, error) }
Extension represents an extension of the Overlord.
type Options ¶
type Options struct { // PebbleDir is the path to the pebble directory. It must be provided. PebbleDir string // RestartHandler is an optional structure to handle restart requests. RestartHandler restart.Handler // ServiceOutput is an optional output for the logging manager. ServiceOutput io.Writer // Extension allows extending the overlord with externally defined features. Extension Extension }
Options is the arguments passed to construct an Overlord.
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 (*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 (*Overlord) CheckManager ¶
func (o *Overlord) CheckManager() *checkstate.CheckManager
CheckManager returns the check manager responsible for running health checks under the overlord.
func (*Overlord) CommandManager ¶
func (o *Overlord) CommandManager() *cmdstate.CommandManager
CommandManager returns the command manager responsible for executing commands under the overlord.
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) ServiceManager ¶
func (o *Overlord) ServiceManager() *servstate.ServiceManager
ServiceManager returns the service manager responsible for services under the overlord.
func (*Overlord) Settle ¶
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. Calls StartUp as well.
func (*Overlord) SettleObserveBeforeCleanups ¶
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. Calls StartUp as well.
func (*Overlord) StartOfOperationTime ¶ added in v1.8.0
func (*Overlord) StateEngine ¶
func (o *Overlord) StateEngine() *StateEngine
StateEngine returns the state engine used by overlord.
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.
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 ¶ added in v1.6.0
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 ¶ added in v1.6.0
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 |
---|---|
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. |