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 ¶
func NewDyingHookSource ¶
NewDyingHookSource returns a new hook.Source that generates all hooks necessary to clean up the supplied initial relation hook state, while preserving the guarantees Juju makes about hook execution order.
func NewLiveHookSource ¶
func NewLiveHookSource(initial *State, w RelationUnitsWatcher) hook.Source
NewLiveHookSource returns a new HookSource that aggregates the values obtained from the w watcher and generates the 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 Source's behaviour is undefined.
Types ¶
type HookQueue ¶
HookQueue exists to keep the package interface stable.
func NewAliveHookQueue ¶
func NewAliveHookQueue(initial *State, out chan<- hook.Info, w RelationUnitsWatcher) HookQueue
NewAliveHookQueue exists to keep the package interface stable; it wraps the result of NewLiveHookSource in a HookSender.
type RelationUnitsWatcher ¶
type RelationUnitsWatcher interface { Err() error Stop() error Changes() <-chan multiwatcher.RelationUnitsChange }
RelationUnitsWatcher produces RelationUnitsChange events until stopped, or until it encounters an error. It must not close its Changes channel without signalling an error via Stop and Err.
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,