Documentation ¶
Overview ¶
Package overlord implements the policies for state transitions for the operation of a snappy system.
Index ¶
- func WriteState(s *State, w io.Writer) error
- type AssertManager
- type Delta
- type DeltaItem
- type Overlord
- type SkillManager
- func (m *SkillManager) Apply(s *State) error
- func (m *SkillManager) Delta(a, b *State) (Delta, error)
- func (m *SkillManager) Grant(s *State, skillSnap, skillName, slotSnap, slotName string) error
- func (m *SkillManager) Learn(s *State) error
- func (m *SkillManager) Revoke(s *State, skillSnap, skillName, slotSnap, slotName string) error
- func (m *SkillManager) Sanitize(s *State) error
- type SnapManager
- func (m *SnapManager) Apply(s *State) error
- func (m *SnapManager) Delta(a, b *State) (Delta, error)
- func (m *SnapManager) Install(s *State, snap string) error
- func (m *SnapManager) Learn(s *State) error
- func (m *SnapManager) Remove(s *State, snap string) error
- func (m *SnapManager) Sanitize(s *State) error
- type State
- type StateEngine
- func (se *StateEngine) AddManager(m StateManager)
- func (se *StateEngine) Apply(s *State) error
- func (se *StateEngine) Delta(a, b *State) (Delta, error)
- func (se *StateEngine) Learn(s *State) error
- func (se *StateEngine) Sanitize(s *State) (Delta, error)
- func (se *StateEngine) Validate(s *State) error
- type StateJournal
- type StateManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AssertManager ¶
type AssertManager struct {
// contains filtered or unexported fields
}
AssertManager is responsible for the enforcement of assertions in system states. It manipulates observed states to ensure nothing in them violates existing assertions, or misses required ones.
func NewAssertManager ¶
func NewAssertManager(o *Overlord) (*AssertManager, error)
NewAssertManager returns a new assertion manager.
func (*AssertManager) Apply ¶
func (m *AssertManager) Apply(s *State) error
Apply implements StateManager.Apply.
func (*AssertManager) Delta ¶
func (m *AssertManager) Delta(a, b *State) (Delta, error)
Delta implements StateManager.Delta.
func (*AssertManager) Learn ¶
func (m *AssertManager) Learn(s *State) error
Learn implements StateManager.Learn.
func (*AssertManager) Sanitize ¶
func (m *AssertManager) Sanitize(s *State) error
Sanitize implements StateManager.Sanitize.
type Delta ¶
type Delta []DeltaItem
Delta represents a list of state changes.
func (Delta) MarshalText ¶
MarshalText returns a human-oriented textual representation of the delta.
This function turns Delta into an encoding.TextMarshaler.
type DeltaItem ¶
type DeltaItem struct { Header string // Header for grouping Summary string // Summary with textual description Reason string // Optional reason for the change, available with sanitization }
DeltaItem represent a single state change, possibly with a reason for it.
type Overlord ¶
type Overlord struct {
// contains filtered or unexported fields
}
Overlord is the central manager of a snappy system, keeping track of all available state managers and related helpers.
func (*Overlord) AssertManager ¶
func (o *Overlord) AssertManager() *AssertManager
AssertManager returns the assertion manager enforcing assertions under the overlord.
func (*Overlord) SkillManager ¶
func (o *Overlord) SkillManager() *SkillManager
SkillManager returns the skill manager mantaining skill assignments under the overlord.
func (*Overlord) SnapManager ¶
func (o *Overlord) SnapManager() *SnapManager
SnapManager returns the snap manager responsible for snaps under the overlord.
func (*Overlord) StateJournal ¶
func (o *Overlord) StateJournal() *StateJournal
StateJournal returns the StateJournal used by the overlord.
type SkillManager ¶
type SkillManager struct {
// contains filtered or unexported fields
}
SkillManager is responsible for the maintenance of skills in system states. It maintains skills assignments, and also observes installed snaps to track the current set of available skills and skill slots.
func NewSkillManager ¶
func NewSkillManager(o *Overlord) (*SkillManager, error)
NewSkillManager returns a new SkillManager.
func (*SkillManager) Apply ¶
func (m *SkillManager) Apply(s *State) error
Apply implements StateManager.Apply.
func (*SkillManager) Delta ¶
func (m *SkillManager) Delta(a, b *State) (Delta, error)
Delta implements StateManager.Delta.
func (*SkillManager) Grant ¶
func (m *SkillManager) Grant(s *State, skillSnap, skillName, slotSnap, slotName string) error
Grant records the intent of granting the skill in state s.
func (*SkillManager) Learn ¶
func (m *SkillManager) Learn(s *State) error
Learn implements StateManager.Learn.
func (*SkillManager) Revoke ¶
func (m *SkillManager) Revoke(s *State, skillSnap, skillName, slotSnap, slotName string) error
Revoke records the intent of revoking the skill in state s.
func (*SkillManager) Sanitize ¶
func (m *SkillManager) Sanitize(s *State) error
Sanitize implements StateManager.Sanitize.
type SnapManager ¶
type SnapManager struct {
// contains filtered or unexported fields
}
SnapManager is responsible for the installation and removal of snaps.
func NewSnapManager ¶
func NewSnapManager(o *Overlord) (*SnapManager, error)
NewSnapManager returns a new snap manager.
func (*SnapManager) Apply ¶
func (m *SnapManager) Apply(s *State) error
Apply implements StateManager.Apply.
func (*SnapManager) Delta ¶
func (m *SnapManager) Delta(a, b *State) (Delta, error)
Delta implements StateManager.Delta.
func (*SnapManager) Install ¶
func (m *SnapManager) Install(s *State, snap string) error
Install records the intent of installing snap in state s.
func (*SnapManager) Learn ¶
func (m *SnapManager) Learn(s *State) error
Learn implements StateManager.Learn.
func (*SnapManager) Remove ¶
func (m *SnapManager) Remove(s *State, snap string) error
Remove records the intent of removing snap in state s.
func (*SnapManager) Sanitize ¶
func (m *SnapManager) Sanitize(s *State) error
Sanitize implements StateManager.Sanitize.
type State ¶
type State struct{}
State represents a snapshot of the system state.
type StateEngine ¶
type StateEngine struct{}
StateEngine controls the dispatching of state changes to state managers.
The operations performed by StateEngine resemble in some ways a transaction system, but it needs to deal with the fact that many of the system changes involved in a snappy system are not atomic, and may actually become invalid without notice (e.g. USB device physically removed).
func (*StateEngine) AddManager ¶
func (se *StateEngine) AddManager(m StateManager)
AddManager adds the provided manager to take part in state operations.
func (*StateEngine) Apply ¶
func (se *StateEngine) Apply(s *State) error
Apply attempts to perform the necessary changes in the system to make s the current state.
func (*StateEngine) Delta ¶
func (se *StateEngine) Delta(a, b *State) (Delta, error)
Delta returns the differences between state a and b, or nil if there are no relevant differences.
func (*StateEngine) Learn ¶
func (se *StateEngine) Learn(s *State) error
Learn records the current state into s.
func (*StateEngine) Sanitize ¶
func (se *StateEngine) Sanitize(s *State) (Delta, error)
Sanitize attempts to make the necessary changes in the provided state to make it ready for applying. It returns a Delta with the changes performed and the reasoning for them.
func (*StateEngine) Validate ¶
func (se *StateEngine) Validate(s *State) error
Validate checks whether the s state might be applied as-is if desired. It's implemented in terms of Sanitize and Delta.
type StateJournal ¶
type StateJournal struct {
// contains filtered or unexported fields
}
StateJournal is responsible for keeping track of multiple states persistently and recording intended state changes so that the system may be properly recovered from an interruption by moving into the intended state completely, or retroceding to a prior good state.
func NewStateJournal ¶
func NewStateJournal(engine *StateEngine, dir string) (*StateJournal, error)
NewStateJournal returns a new state journal using dir as its configuration directory.
func (*StateJournal) Commit ¶
func (j *StateJournal) Commit(s *State) error
Commit attempts to apply the s state, recording it in the journal first to ensure the operation may be continued later if necessary.
func (*StateJournal) Current ¶
func (j *StateJournal) Current() (*State, error)
Current returns the current system state.
func (*StateJournal) Pending ¶
func (j *StateJournal) Pending() (*State, error)
Pending returns the last attempted but unfinished commit, if any. It returns ErrNotPending if there are no pending states.
func (*StateJournal) Recover ¶
func (j *StateJournal) Recover() error
Recover attempts to apply the currently pending state, if any. If applying the pending state fails for any reason and there's a previous good state, applying that will be attempted instead.
func (*StateJournal) Revert ¶
func (j *StateJournal) Revert() error
Revert attempts to revert the system to the previous known good state, whether the current state is valid or not. This is unlike Recover in that it ignores whether a pending state exists.
type StateManager ¶
type StateManager interface { Apply(s *State) error Learn(s *State) error Sanitize(s *State) error Delta(a, b *State) (Delta, error) }
StateManager is implemented by types responsible for observing the system state and directly manipulating it.
See the interface of StateEngine for details on those methods.