watcher

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

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

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 10 Imported by: 87

Documentation

Index

Constants

View Source
const (
	StatusRed    = "red"
	StatusYellow = "yellow" // amber?
	StatusGreen  = "green"
)

Status values show a high level indicator of model health.

Variables

This section is empty.

Functions

This section is empty.

Types

type EntitiesWatcher

type EntitiesWatcher = StringsWatcher

EntitiesWatcher delivers strings that can be parsed as tags, but since it doesn't actually produce tags today we may as well make it compatible with StringsWatcher so we can use it with a StringsHandler. In an ideal world we'd have something like `type EntitiesChannel <-chan []names.Tag` instead.

type MachineStorageID

type MachineStorageID struct {
	MachineTag    string
	AttachmentTag string
}

MachineStorageID associates a machine entity with a storage entity. They're expressed as tags because they arrived here as a move, not a change; ideally a MachineStorageIDsWatcher would return them in a more model-appropriate format (i.e. not as strings-that-probably-parse-to-tags).

type MachineStorageIDsChannel

type MachineStorageIDsChannel = <-chan []MachineStorageID

MachineStorageIDsChannel is a change channel as described in the CoreWatcher docs.

It reports additions and removals to a set of attachments; and lifecycle changes within the active set. This is deprecated; use <-chan []MachineStorageID instead.

type MachineStorageIDsWatcher

type MachineStorageIDsWatcher = Watcher[[]MachineStorageID]

MachineStorageIDsWatcher reports additions and removals to a set of attachments; and lifecycle changes within the active set.

type MigrationStatus

type MigrationStatus struct {
	MigrationId    string
	Attempt        int
	Phase          migration.Phase
	SourceAPIAddrs []string
	SourceCACert   string
	TargetAPIAddrs []string
	TargetCACert   string
}

MigrationStatus is the client side version of params.MigrationStatus.

type MigrationStatusWatcher

type MigrationStatusWatcher = Watcher[MigrationStatus]

MigrationStatusWatcher describes a watcher that reports the latest status of a migration for a model.

type ModelSummary

type ModelSummary struct {
	UUID string
	// Removed indicates that the user can no longer see this model, because it has
	// either been removed, or there access revoked.
	Removed bool

	Controller  string
	Namespace   string
	Name        string
	Admins      []string
	Status      string
	Annotations map[string]string

	// Messages contain status message for any unit status in error.
	Messages []ModelSummaryMessage

	Cloud        string
	Region       string
	Credential   string
	LastModified time.Time // Currently missing in cache and underlying db model.

	// MachineCount is just top level machines.
	MachineCount     int
	ContainerCount   int
	ApplicationCount int
	UnitCount        int
	RelationCount    int
}

ModelSummary represents a high level view of a model. Primary use case is to drive a dashboard with model level overview.

type ModelSummaryMessage

type ModelSummaryMessage struct {
	Agent   string
	Message string
}

ModelSummaryMessage holds information about an error message from an agent, and when that message was set.

type ModelSummaryWatcher

type ModelSummaryWatcher = Watcher[[]ModelSummary]

ModelSummaryWatcher will return a slice for all existing models

type NotifyChannel

type NotifyChannel = <-chan struct{}

NotifyChannel is a channel that receives a single value to indicate that the watch is active, and subsequent values whenever the value(s) under observation change(s). This is deprecated; use <-chan struct{} instead.

type NotifyConfig

type NotifyConfig struct {
	Handler NotifyHandler
}

NotifyConfig holds the direct dependencies of a NotifyWorker.

func (NotifyConfig) Validate

func (config NotifyConfig) Validate() error

Validate returns an error if the config cannot start a NotifyWorker.

type NotifyHandler

type NotifyHandler interface {

	// SetUp is called once when creating a NotifyWorker. It must return a
	// NotifyWatcher or an error. The NotifyHandler takes responsibility for
	// stopping any returned watcher and handling any errors.
	SetUp(context.Context) (NotifyWatcher, error)

	// Handle is called whenever a value is received from the NotifyWatcher
	// returned by SetUp. If it returns an error, the NotifyWorker will be
	// stopped.
	//
	// If Handle runs any blocking operations it must pass through, or select
	// on, the supplied context done channel; the context will be canceled when
	// the NotifyWorker is killed. An aborted Handle should not return an error.
	Handle(context.Context) error

	// TearDown is called once when stopping a NotifyWorker, whether or not
	// SetUp succeeded. It need not concern itself with the NotifyWatcher, but
	// must clean up any other resources created in SetUp or Handle.
	TearDown() error
}

NotifyHandler defines the operation of a NotifyWorker.

type NotifyWatcher

type NotifyWatcher = Watcher[struct{}]

NotifyWatcher sends a single value to indicate that the watch is active, and subsequent values whenever the value(s) under observation change(s).

func Normalise

func Normalise[T any](source Watcher[T]) (NotifyWatcher, error)

Normalise takes any watcher and normalises it down to a NotifyWatcher. This is useful in legacy code that expects a NotifyWatcher.

type NotifyWorker

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

NotifyWorker is a worker that wraps a NotifyWatcher.

func NewNotifyWorker

func NewNotifyWorker(config NotifyConfig) (*NotifyWorker, error)

NewNotifyWorker starts a new worker that runs a NotifyHandler.

func (*NotifyWorker) Kill

func (nw *NotifyWorker) Kill()

Kill is part of the worker.Worker interface.

func (*NotifyWorker) Report

func (nw *NotifyWorker) Report() map[string]interface{}

Report implements dependency.Reporter.

func (*NotifyWorker) Wait

func (nw *NotifyWorker) Wait() error

Wait is part of the worker.Worker interface.

type OfferStatusChange

type OfferStatusChange struct {
	// Name is the name of the offer.
	Name string

	// Status is the status of the offer.
	Status status.StatusInfo
}

OfferStatusChange describes changes to some offer.

type OfferStatusChannel

type OfferStatusChannel = <-chan []OfferStatusChange

OfferStatusChannel is a channel used to notify of changes to an offer's status. This is deprecated; use <-chan []OfferStatusChange instead.

type OfferStatusWatcher

type OfferStatusWatcher = Watcher[[]OfferStatusChange]

OfferStatusWatcher returns a slice of OfferStatusChanges when an offer's status changes.

type RelationStatusChange

type RelationStatusChange struct {
	// Key is the relation key of the changed relation.
	Key string

	// Suspended is the suspended status of the relation.
	Suspended bool

	// SuspendedReason is an optional message to explain why suspend is true.
	SuspendedReason string

	// Life is the relation life value, eg Alive.
	Life life.Value
}

RelationStatusChange describes changes to some relation.

type RelationStatusChannel

type RelationStatusChannel = <-chan []RelationStatusChange

RelationStatusChannel is a channel used to notify of changes to a relation's life or suspended status. This is deprecated; use <-chan []RelationStatusChange instead.

type RelationStatusWatcher

type RelationStatusWatcher = Watcher[[]RelationStatusChange]

RelationStatusWatcher returns a slice of RelationStatusChanges when a relation's life or suspended status changes.

type RelationUnitsChange

type RelationUnitsChange struct {

	// Changed holds a set of units that are known to be in scope, and the
	// latest known settings version for each.
	Changed map[string]UnitSettings

	// AppChanged holds the latest known settings version for associated
	// applications.
	AppChanged map[string]int64

	// Departed holds a set of units that have previously been reported to
	// be in scope, but which no longer are.
	Departed []string
}

RelationUnitsChange describes the membership and settings of; or changes to; some relation scope.

type RelationUnitsChannel

type RelationUnitsChannel = <-chan RelationUnitsChange

RelationUnitsChannel is a change channel as described in the CoreWatcher docs.

It sends a single value representing the current membership of a relation scope; and the versions of the settings documents for each; and subsequent values representing entry, settings-change, and departure for units in that scope.

It feeds the joined-changed-departed logic in worker/uniter, but these events do not map 1:1 with hooks. This is deprecated; use <-chan RelationUnitsChange instead.

type RelationUnitsWatcher

type RelationUnitsWatcher = Watcher[RelationUnitsChange]

RelationUnitsWatcher sends a single value representing the current membership of a relation scope; and the versions of the settings documents for each; and subsequent values representing entry, settings-change, and departure for units in that scope.

It feeds the joined-changed-departed logic in worker/uniter, but these events do not map 1:1 with hooks.

type SecretBackendRotateChange

type SecretBackendRotateChange struct {
	ID              string
	Name            string
	NextTriggerTime time.Time
}

SecretBackendRotateChange describes changes to a secret backend rotation trigger.

func (SecretBackendRotateChange) GoString

func (s SecretBackendRotateChange) GoString() string

type SecretBackendRotateChannel

type SecretBackendRotateChannel = <-chan []SecretBackendRotateChange

SecretBackendRotateChannel is a change channel as described in the CoreWatcher docs. This is deprecated; use <-chan []SecretBackendRotateChange instead.

type SecretBackendRotateWatcher

type SecretBackendRotateWatcher = Watcher[[]SecretBackendRotateChange]

SecretBackendRotateWatcher represents a watcher that returns a slice of SecretBackendRotateChange.

type SecretRevisionChange

type SecretRevisionChange struct {
	URI      *secrets.URI
	Revision int
}

SecretRevisionChange describes changes to a secret.

func (SecretRevisionChange) GoString

func (s SecretRevisionChange) GoString() string

type SecretRevisionChannel

type SecretRevisionChannel = <-chan []SecretRevisionChange

SecretRevisionChannel is a channel used to notify of changes to a secret. This is deprecated; use <-chan []SecretRevisionChange instead.

type SecretTriggerChange

type SecretTriggerChange struct {
	URI             *secrets.URI
	Revision        int
	NextTriggerTime time.Time
}

SecretTriggerChange describes changes to a secret trigger. eg rotation or expiry.

func (SecretTriggerChange) GoString

func (s SecretTriggerChange) GoString() string

GoString returns a Go-syntax representation of the change.

func (SecretTriggerChange) String

func (s SecretTriggerChange) String() string

String returns a string representation of the change.

type SecretTriggerChannel

type SecretTriggerChannel = <-chan []SecretTriggerChange

SecretTriggerChannel is a change channel as described in the CoreWatcher docs. This is deprecated; use <-chan []SecretTriggerChange instead.

type SecretTriggerWatcher

type SecretTriggerWatcher = Watcher[[]SecretTriggerChange]

SecretTriggerWatcher represents a watcher that reports the latest trigger of a secret.

type SecretsRevisionWatcher

type SecretsRevisionWatcher = Watcher[[]SecretRevisionChange]

SecretsRevisionWatcher represents a watcher that reports the latest revision of a secret.

type StringsChannel

type StringsChannel = <-chan []string

StringsChannel is a channel that receives a baseline set of values, and subsequent values representing additions, changes, and/or removals of those values. This is deprecated; use <-chan []string instead.

type StringsConfig

type StringsConfig struct {
	Handler StringsHandler
}

StringsConfig holds the direct dependencies of a StringsWorker.

func (StringsConfig) Validate

func (config StringsConfig) Validate() error

Validate returns ann error if the config cannot start a StringsWorker.

type StringsHandler

type StringsHandler interface {

	// SetUp is called once when creating a StringsWorker. It must return a
	// StringsWatcher or an error. The StringsHandler takes responsibility for
	// stopping any returned watcher and handling any errors.
	SetUp(ctx context.Context) (StringsWatcher, error)

	// Handle is called with every value received from the StringsWatcher
	// returned by SetUp. If it returns an error, the StringsWorker will be
	// stopped.
	//
	// If Handle runs any blocking operations it must pass through, or select
	// on, the supplied abort channel; this channel will be closed when the
	// StringsWorker is killed. An aborted Handle should not return an error.
	Handle(ctx context.Context, changes []string) error

	// TearDown is called once when stopping a StringsWorker, whether or not
	// SetUp succeeded. It need not concern itself with the StringsWatcher, but
	// must clean up any other resources created in SetUp or Handle.
	TearDown() error
}

StringsHandler defines the operation of a StringsWorker.

type StringsWatcher

type StringsWatcher = Watcher[[]string]

StringsWatcher sends a single value indicating a baseline set of values, and subsequent values representing additions, changes, and/or removals of those values.

type StringsWorker

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

StringsWorker is a worker that wraps a StringsWatcher.

func NewStringsWorker

func NewStringsWorker(config StringsConfig) (*StringsWorker, error)

NewStringsWorker starts a new worker that runs a StringsHandler.

func (*StringsWorker) Kill

func (sw *StringsWorker) Kill()

Kill is part of the worker.Worker interface.

func (*StringsWorker) Report

func (sw *StringsWorker) Report() map[string]interface{}

Report implements dependency.Reporter.

func (*StringsWorker) Wait

func (sw *StringsWorker) Wait() error

Wait is part of the worker.Worker interface.

type UnitSettings

type UnitSettings struct {
	Version int64
}

UnitSettings specifies the version of some unit's settings in some relation.

type Watcher

type Watcher[T any] interface {
	worker.Worker

	// Changes returns a channel of type T, that will be closed when the watcher
	// is stopped.
	Changes() <-chan T
}

Watcher defines a worker that defines changes for a given type of T.

func TODO

func TODO[T any]() Watcher[T]

TODO returns a watcher for type T that sends an initial change with the empty value of type T.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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