Documentation ¶
Overview ¶
relation implements persistent local storage of a unit's relation state, and translation of relation changes into hooks that need to be run.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AliveHookQueue ¶
type AliveHookQueue struct {
// contains filtered or unexported fields
}
AliveHookQueue aggregates values obtained from a relation units watcher and sends out details about hooks that must be executed in the unit.
func NewAliveHookQueue ¶
func NewAliveHookQueue(initial *State, out chan<- hook.Info, w RelationUnitsWatcher) *AliveHookQueue
NewAliveHookQueue returns a new AliveHookQueue that aggregates the values obtained from the w watcher and sends into out the details about hooks that must be executed in the unit. It guarantees that the stream of hooks will respect the guarantees Juju makes about hook execution order. If any values have previously been received from w's Changes channel, the AliveHookQueue's behaviour is undefined.
func (*AliveHookQueue) Stop ¶
func (q *AliveHookQueue) Stop() error
Stop stops the AliveHookQueue and returns any errors encountered during operation or while shutting down.
type DyingHookQueue ¶
type DyingHookQueue struct {
// contains filtered or unexported fields
}
DyingHookQueue is a hook queue that deals with a relation that is being shut down. It honours the obligations of an AliveHookQueue with respect to relation hook execution order; as soon as those obligations are fulfilled, it sends a "relation-departed" hook for every relation member, and finally a "relation-broken" hook for the relation itself.
func NewDyingHookQueue ¶
func NewDyingHookQueue(initial *State, out chan<- hook.Info) *DyingHookQueue
NewDyingHookQueue returns a new DyingHookQueue that shuts down the state in initial.
func (*DyingHookQueue) Stop ¶
func (q *DyingHookQueue) Stop() error
Stop stops the DyingHookQueue and returns any errors encountered during operation or while shutting down.
type HookQueue ¶
type HookQueue interface { Stop() error // contains filtered or unexported methods }
HookQueue is the minimal interface implemented by both AliveHookQueue and DyingHookQueue.
type RelationUnitsWatcher ¶
type RelationUnitsWatcher interface { Err() error Stop() error Changes() <-chan params.RelationUnitsChange }
RelationUnitsWatcher is used to enable deterministic testing of AliveHookQueue, by supplying a reliable stream of RelationUnitsChange events; usually, it will be a *state.RelationUnitsWatcher.
type State ¶
type State struct { // RelationId identifies the relation. RelationId int // Members is a map from unit name to the last change version // for which a hook.Info was delivered on the output channel. Members map[string]int64 // ChangedPending indicates that a "relation-changed" hook for the given // unit name must be the first hook.Info to be sent to the output channel. ChangedPending string }
State describes the state of a relation.
type StateDir ¶
type StateDir struct {
// contains filtered or unexported fields
}
StateDir is a filesystem-backed representation of the state of a relation. Concurrent modifications to the underlying state directory will have undefined consequences.
func ReadStateDir ¶
ReadStateDir loads a StateDir from the subdirectory of dirPath named for the supplied RelationId. If the directory does not exist, no error is returned,