remotestate

package
v0.0.0-...-4bd6544 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2016 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application interface {
	// CharmModifiedVersion returns a revision number for the charm that
	// increments whenever the charm or a resource for the charm changes.
	CharmModifiedVersion() (int, error)
	// CharmURL returns the url for the charm for this service.
	CharmURL() (*charm.URL, bool, error)
	// Life returns whether the service is alive.
	Life() params.Life
	// Refresh syncs this value with the api server.
	Refresh() error
	// Tag returns the tag for this service.
	Tag() names.ApplicationTag
	// Watch returns a watcher that fires when this service changes.
	Watch() (watcher.NotifyWatcher, error)
	// WatchLeadershipSettings returns a watcher that fires when the leadership
	// settings for this service change.
	WatchLeadershipSettings() (watcher.NotifyWatcher, error)
	// WatchRelation returns a watcher that fires when the relations on this
	// service change.
	WatchRelations() (watcher.StringsWatcher, error)
}

type Relation

type Relation interface {
	Id() int
	Life() params.Life
}

type RelationSnapshot

type RelationSnapshot struct {
	Life    params.Life
	Members map[string]int64
}

type RemoteStateWatcher

type RemoteStateWatcher struct {
	// contains filtered or unexported fields
}

RemoteStateWatcher collects unit, service, and service config information from separate state watchers, and updates a Snapshot which is sent on a channel upon change.

func NewWatcher

func NewWatcher(config WatcherConfig) (*RemoteStateWatcher, error)

NewWatcher returns a RemoteStateWatcher that handles state changes pertaining to the supplied unit.

func (*RemoteStateWatcher) ClearResolvedMode

func (w *RemoteStateWatcher) ClearResolvedMode()

func (*RemoteStateWatcher) CommandCompleted

func (w *RemoteStateWatcher) CommandCompleted(completed string)

func (*RemoteStateWatcher) Kill

func (w *RemoteStateWatcher) Kill()

Kill is part of the worker.Worker interface.

func (*RemoteStateWatcher) RemoteStateChanged

func (w *RemoteStateWatcher) RemoteStateChanged() <-chan struct{}

func (*RemoteStateWatcher) Snapshot

func (w *RemoteStateWatcher) Snapshot() Snapshot

func (*RemoteStateWatcher) Wait

func (w *RemoteStateWatcher) Wait() error

Wait is part of the worker.Worker interface.

type Snapshot

type Snapshot struct {
	// Life is the lifecycle state of the unit.
	Life params.Life

	// Relations contains the lifecycle states of
	// each of the service's relations, keyed by
	// relation IDs.
	Relations map[int]RelationSnapshot

	// Storage contains the lifecycle and attached
	// states of each of the unit's storage attachments.
	Storage map[names.StorageTag]StorageSnapshot

	// CharmModifiedVersion is increased whenever the service's charm was
	// changed in some way.
	CharmModifiedVersion int

	// CharmURL is the charm URL that the unit is
	// expected to run.
	CharmURL *charm.URL

	// ForceCharmUpgrade reports whether the unit
	// should upgrade even in an error state.
	ForceCharmUpgrade bool

	// ResolvedMode reports the method of resolving
	// hook execution errors.
	ResolvedMode params.ResolvedMode

	// RetryHookVersion increments each time a failed
	// hook is meant to be retried if ResolvedMode is
	// set to ResolvedNone.
	RetryHookVersion int

	// ConfigVersion is the last published version of
	// the unit's config settings.
	ConfigVersion int

	// Leader indicates whether or not the unit is the
	// elected leader.
	Leader bool

	// LeaderSettingsVersion is the last published
	// version of the leader settings for the application.
	LeaderSettingsVersion int

	// UpdateStatusVersion increments each time an
	// update-status hook is supposed to run.
	UpdateStatusVersion int

	// Actions is the list of pending actions to
	// be peformed by this unit.
	Actions []string

	// Commands is the list of IDs of commands to be
	// executed by this unit.
	Commands []string
}

Snapshot is a snapshot of the remote state of the unit.

type State

type State interface {
	Relation(names.RelationTag) (Relation, error)
	StorageAttachment(names.StorageTag, names.UnitTag) (params.StorageAttachment, error)
	StorageAttachmentLife([]params.StorageAttachmentId) ([]params.LifeResult, error)
	Unit(names.UnitTag) (Unit, error)
	WatchRelationUnits(names.RelationTag, names.UnitTag) (watcher.RelationUnitsWatcher, error)
	WatchStorageAttachment(names.StorageTag, names.UnitTag) (watcher.NotifyWatcher, error)
}

func NewAPIState

func NewAPIState(st *uniter.State) State

type StorageAccessor

type StorageAccessor interface {
	// StorageAttachment returns the storage attachment with the specified
	// unit and storage tags.
	StorageAttachment(names.StorageTag, names.UnitTag) (params.StorageAttachment, error)
}

type StorageSnapshot

type StorageSnapshot struct {
	Kind     params.StorageKind
	Life     params.Life
	Attached bool
	Location string
}

StorageSnapshot has information relating to a storage instance belonging to a unit.

type Unit

type Unit interface {
	Life() params.Life
	Refresh() error
	Resolved() (params.ResolvedMode, error)
	Application() (Application, error)
	Tag() names.UnitTag
	Watch() (watcher.NotifyWatcher, error)
	WatchAddresses() (watcher.NotifyWatcher, error)
	WatchConfigSettings() (watcher.NotifyWatcher, error)
	WatchStorage() (watcher.StringsWatcher, error)
	WatchActionNotifications() (watcher.StringsWatcher, error)
}

type Watcher

type Watcher interface {
	// RemoteStateChanged returns a channel which is signalled
	// whenever the remote state is changed.
	RemoteStateChanged() <-chan struct{}

	// Snapshot returns the current snapshot of the remote state.
	Snapshot() Snapshot

	worker.Worker
}

type WatcherConfig

type WatcherConfig struct {
	State               State
	LeadershipTracker   leadership.Tracker
	UpdateStatusChannel func() <-chan time.Time
	CommandChannel      <-chan string
	RetryHookChannel    <-chan struct{}
	UnitTag             names.UnitTag
}

WatcherConfig holds configuration parameters for the remote state watcher.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL