Documentation ¶
Overview ¶
hook provides types that define the hooks known to the Uniter
Index ¶
Constants ¶
const ( LeaderElected hooks.Kind = "leader-elected" LeaderDeposed hooks.Kind = "leader-deposed" LeaderSettingsChanged hooks.Kind = "leader-settings-changed" )
TODO(fwereade): move these definitions to juju/charm/hooks.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Committer ¶
Committer is an interface that may be used to convey the fact that the specified hook has been successfully executed, and committed.
type Info ¶
type Info struct { Kind hooks.Kind `yaml:"kind"` // RelationId identifies the relation associated with the hook. It is // only set when Kind indicates a relation hook. RelationId int `yaml:"relation-id,omitempty"` // RemoteUnit is the name of the unit that triggered the hook. It is only // set when Kind indicates a relation hook other than relation-broken. RemoteUnit string `yaml:"remote-unit,omitempty"` // ChangeVersion identifies the most recent unit settings change // associated with RemoteUnit. It is only set when RemoteUnit is set. ChangeVersion int64 `yaml:"change-version,omitempty"` // StorageId is the ID of the storage instance relevant to the hook. StorageId string `yaml:"storage-id,omitempty"` }
Info holds details required to execute a hook. Not all fields are relevant to all Kind values.
type NoUpdates ¶
type NoUpdates struct{}
NoUpdates implements a subset of HookSource that delivers no changes, errors on update, and ignores stop requests (because there's nothing running in the first place). It's useful for implementing static HookSources.
func (*NoUpdates) Changes ¶
func (_ *NoUpdates) Changes() <-chan SourceChange
type Peek ¶
type Peek interface { // HookInfo returns information about the hook at the head of the queue. HookInfo() Info // Consume pops the hook from the head of the queue and makes new Peeks // available. Consume() // Reject makes new Peeks available. Reject() }
Peek exists to support Peeker and has no independent meaning or existence. Receiving a Peek from a Peeker's Peek channel implies acceptance of the responsibility to either Consume or Reject the Peek.
type Peeker ¶
type Peeker interface { // Peeks returns a channel on which Peeks are delivered. The receiver of a // Peek must Consume or Reject the Peek before further peeks will be sent. Peeks() <-chan Peek // Stop stops the Peeker's Source, and prevents any further Peeks from // being delivered. Stop() error }
Peeker maintains a Source, and allows an external client to inspect and consume, or reject, the head of the queue.
type Sender ¶
type Sender interface {
Stop() error
}
Sender maintains a Source and delivers its hooks via a channel.
type Source ¶
type Source interface { // Changes returns a channel sending events which must be processed // synchronously, and in order. Changes() <-chan SourceChange // Stop causes the Source to clean up its resources and stop sending // changes. Stop() error // Empty returns false if any hooks are scheduled. Empty() bool // Next returns the first scheduled hook. It will panic if no hooks are // scheduled. Next() Info // Pop removes the first scheduled hook, and invalidates the results of // previous calls to Next() and Empty(). It will panic if no hooks are // scheduled. Pop() }
Source defines a generator of Info events.
A Source's client must be careful to:
- use it from a single goroutine.
- collect asynchronous events from Changes(), and synchronously Apply() them whenever possible.
- only use fresh values returned from Empty() and Next(); i.e. only those which have been generated since the last call to Pop() or Update().
- Stop() it when finished.
func NewListSource ¶
NewListSource returns a Source that generates only the supplied hooks, in order; and which cannot be updated.
type SourceChange ¶
type SourceChange func() error
SourceChange is the type of functions returned via Source.Changes().
func (SourceChange) Apply ¶
func (s SourceChange) Apply() error
Apply applies the change to its Source's schedule, and invalidates the results of previous calls to Next() and Empty().