juju: github.com/juju/juju/core/multiwatcher Index | Files

package multiwatcher

import "github.com/juju/juju/core/multiwatcher"

Index

Package Files

stopped.go store.go types.go

Constants

const (
    ActionKind            = "action"
    AnnotationKind        = "annotation" // the annotations should really be parts of the other entities
    ApplicationKind       = "application"
    ApplicationOfferKind  = "applicationOffer"
    BlockKind             = "block"
    BranchKind            = "branch"
    CharmKind             = "charm"
    MachineKind           = "machine"
    ModelKind             = "model"
    RelationKind          = "relation"
    RemoteApplicationKind = "remoteApplication"
    UnitKind              = "unit"
)

The kind constants are there to stop typos when switching on kinds.

func ErrStoppedf Uses

func ErrStoppedf(format string, args ...interface{}) error

ErrStoppedf returns an error which satisfies IsErrStopped().

func IsErrStopped Uses

func IsErrStopped(err error) bool

IsErrStopped reports whether the error was created with ErrStoppedf() or NewErrStopped().

func NewErrStopped Uses

func NewErrStopped() error

NewErrStopped returns an error which wraps err and satisfies IsErrStopped().

type ActionInfo Uses

type ActionInfo struct {
    ModelUUID  string
    ID         string
    Receiver   string
    Name       string
    Parameters map[string]interface{}
    Status     string
    Message    string
    Results    map[string]interface{}
    Enqueued   time.Time
    Started    time.Time
    Completed  time.Time
}

ActionInfo holds the information about a action that is tracked by multiwatcherStore.

func (*ActionInfo) Clone Uses

func (i *ActionInfo) Clone() EntityInfo

Clone returns a clone of the EntityInfo.

func (*ActionInfo) EntityID Uses

func (i *ActionInfo) EntityID() EntityID

EntityID returns a unique identifier for an action across models.

type AnnotationInfo Uses

type AnnotationInfo struct {
    ModelUUID   string
    Tag         string
    Annotations map[string]string
}

AnnotationInfo holds the information about an annotation that is tracked by multiwatcherStore.

func (*AnnotationInfo) Clone Uses

func (i *AnnotationInfo) Clone() EntityInfo

Clone returns a clone of the EntityInfo.

func (*AnnotationInfo) EntityID Uses

func (i *AnnotationInfo) EntityID() EntityID

EntityID returns a unique identifier for an annotation across models.

type ApplicationInfo Uses

type ApplicationInfo struct {
    ModelUUID       string
    Name            string
    Exposed         bool
    CharmURL        string
    OwnerTag        string
    Life            life.Value
    MinUnits        int
    Constraints     constraints.Value
    Annotations     map[string]string
    Config          map[string]interface{}
    Subordinate     bool
    Status          StatusInfo
    OperatorStatus  StatusInfo // For CAAS models.
    WorkloadVersion string
    PodSpec         *PodSpec // For CAAS models.
}

ApplicationInfo holds the information about an application that is tracked by multiwatcherStore.

func (*ApplicationInfo) Clone Uses

func (i *ApplicationInfo) Clone() EntityInfo

Clone returns a clone of the EntityInfo.

func (*ApplicationInfo) EntityID Uses

func (i *ApplicationInfo) EntityID() EntityID

EntityID returns a unique identifier for an application across models.

type ApplicationOfferInfo Uses

type ApplicationOfferInfo struct {
    ModelUUID            string
    OfferName            string
    OfferUUID            string
    ApplicationName      string
    CharmName            string
    TotalConnectedCount  int
    ActiveConnectedCount int
}

ApplicationOfferInfo holds the information about an application offer that is tracked by multiwatcherStore.

func (*ApplicationOfferInfo) Clone Uses

func (i *ApplicationOfferInfo) Clone() EntityInfo

Clone returns a clone of the EntityInfo.

func (*ApplicationOfferInfo) EntityID Uses

func (i *ApplicationOfferInfo) EntityID() EntityID

EntityID returns a unique identifier for an application offer across models.

type BlockInfo Uses

type BlockInfo struct {
    ModelUUID string
    ID        string
    Type      model.BlockType
    Message   string
    Tag       string
}

BlockInfo holds the information about a block that is tracked by multiwatcherStore.

func (*BlockInfo) Clone Uses

func (i *BlockInfo) Clone() EntityInfo

Clone returns a clone of the EntityInfo.

func (*BlockInfo) EntityID Uses

func (i *BlockInfo) EntityID() EntityID

EntityID returns a unique identifier for a block across models.

type BranchInfo Uses

type BranchInfo struct {
    ModelUUID     string
    ID            string
    Name          string
    AssignedUnits map[string][]string
    Config        map[string][]ItemChange
    Created       int64
    CreatedBy     string
    Completed     int64
    CompletedBy   string
    GenerationID  int
}

BranchInfo holds data about a model branch that is tracked by multiwatcherStore.

func (*BranchInfo) Clone Uses

func (i *BranchInfo) Clone() EntityInfo

Clone returns a clone of the EntityInfo.

func (*BranchInfo) EntityID Uses

func (i *BranchInfo) EntityID() EntityID

EntityID returns a unique identifier for a generation.

type CharmInfo Uses

type CharmInfo struct {
    ModelUUID    string
    CharmURL     string
    CharmVersion string
    Life         life.Value
    LXDProfile   *Profile
    // DefaultConfig is derived from state-stored *charm.Config.
    DefaultConfig map[string]interface{}
}

CharmInfo holds the information about a charm that is tracked by the multiwatcher.

func (*CharmInfo) Clone Uses

func (i *CharmInfo) Clone() EntityInfo

Clone returns a clone of the EntityInfo.

func (*CharmInfo) EntityID Uses

func (i *CharmInfo) EntityID() EntityID

EntityID returns a unique identifier for an charm across models.

type CharmRelation Uses

type CharmRelation struct {
    Name      string
    Role      string
    Interface string
    Optional  bool
    Limit     int
    Scope     string
}

CharmRelation mirrors charm.Relation.

type Delta Uses

type Delta struct {
    // If Removed is true, the entity has been removed;
    // otherwise it has been created or changed.
    Removed bool
    // Entity holds data about the entity that has changed.
    Entity EntityInfo
}

Delta holds details of a change to the model.

type Endpoint Uses

type Endpoint struct {
    ApplicationName string
    Relation        CharmRelation
}

Endpoint holds an application-relation pair.

type EntityID Uses

type EntityID struct {
    Kind      string
    ModelUUID string
    ID        string
}

EntityID uniquely identifies an entity being tracked by the multiwatcherStore.

type EntityInfo Uses

type EntityInfo interface {
    // EntityID returns an identifier that will uniquely
    // identify the entity within its kind
    EntityID() EntityID

    // Clone returns a clone of the EntityInfo.
    Clone() EntityInfo
}

EntityInfo is implemented by all entity Info types.

type Factory Uses

type Factory interface {
    // TODO: WatchUsersModels to filter just the user's models
    WatchModel(modelUUID string) Watcher
    WatchController() Watcher
}

Factory is used to create multiwatchers.

type ItemChange Uses

type ItemChange struct {
    Type     int
    Key      string
    OldValue interface{}
    NewValue interface{}
}

ItemChange is the multiwatcher representation of a core settings ItemChange.

type Logger Uses

type Logger interface {
    IsTraceEnabled() bool
    Tracef(string, ...interface{})
    Errorf(string, ...interface{})
    Criticalf(string, ...interface{})
}

Logger describes the logging methods used in this package by the worker.

type MachineInfo Uses

type MachineInfo struct {
    ModelUUID                string
    ID                       string
    InstanceID               string
    AgentStatus              StatusInfo
    InstanceStatus           StatusInfo
    Life                     life.Value
    Annotations              map[string]string
    Config                   map[string]interface{}
    Series                   string
    ContainerType            string
    IsManual                 bool
    SupportedContainers      []instance.ContainerType
    SupportedContainersKnown bool
    HardwareCharacteristics  *instance.HardwareCharacteristics
    CharmProfiles            []string
    Jobs                     []model.MachineJob
    Addresses                []network.ProviderAddress
    HasVote                  bool
    WantsVote                bool

    // The preferred public and preferred private address are
    // only stored on the machine info to populate the unit info.
    PreferredPublicAddress  network.SpaceAddress
    PreferredPrivateAddress network.SpaceAddress
}

MachineInfo holds the information about a machine that is tracked by multiwatcherStore.

func (*MachineInfo) Clone Uses

func (i *MachineInfo) Clone() EntityInfo

Clone returns a clone of the EntityInfo.

func (*MachineInfo) EntityID Uses

func (i *MachineInfo) EntityID() EntityID

EntityID returns a unique identifier for a machine across models.

type ModelInfo Uses

type ModelInfo struct {
    ModelUUID       string
    Type            model.ModelType
    Name            string
    Life            life.Value
    Owner           string
    ControllerUUID  string
    IsController    bool
    Cloud           string
    CloudRegion     string
    CloudCredential string
    Annotations     map[string]string
    Config          map[string]interface{}
    Status          StatusInfo
    Constraints     constraints.Value
    SLA             ModelSLAInfo

    UserPermissions map[string]permission.Access
}

ModelInfo holds the information about a model that is tracked by multiwatcherStore.

func (*ModelInfo) Clone Uses

func (i *ModelInfo) Clone() EntityInfo

Clone returns a clone of the EntityInfo.

func (*ModelInfo) EntityID Uses

func (i *ModelInfo) EntityID() EntityID

EntityID returns a unique identifier for a model.

type ModelSLAInfo Uses

type ModelSLAInfo struct {
    Level string
    Owner string
}

ModelSLAInfo describes the SLA info for a model.

type PodSpec Uses

type PodSpec struct {
    Spec    string
    Raw     bool
    Counter int
}

PodSpec is used to determine whether or not a CAAS application has called the command to set the pod spec.

type Profile Uses

type Profile struct {
    Config      map[string]string
    Description string
    Devices     map[string]map[string]string
}

Profile is a representation of charm.v6 LXDProfile

func (*Profile) Clone Uses

func (p *Profile) Clone() *Profile

type RelationInfo Uses

type RelationInfo struct {
    ModelUUID string
    Key       string
    ID        int
    Endpoints []Endpoint
}

RelationInfo holds the information about a relation that is tracked by multiwatcherStore.

func (*RelationInfo) Clone Uses

func (i *RelationInfo) Clone() EntityInfo

Clone returns a clone of the EntityInfo.

func (*RelationInfo) EntityID Uses

func (i *RelationInfo) EntityID() EntityID

EntityID returns a unique identifier for a relation across models.

type RemoteApplicationUpdate Uses

type RemoteApplicationUpdate struct {
    ModelUUID string
    Name      string
    OfferUUID string
    OfferURL  string
    Life      life.Value
    Status    StatusInfo
}

RemoteApplicationUpdate holds the information about a remote application that is tracked by multiwatcherStore.

func (*RemoteApplicationUpdate) Clone Uses

func (i *RemoteApplicationUpdate) Clone() EntityInfo

Clone returns a clone of the EntityInfo.

func (*RemoteApplicationUpdate) EntityID Uses

func (i *RemoteApplicationUpdate) EntityID() EntityID

EntityID returns a unique identifier for a remote application across models.

type StatusInfo Uses

type StatusInfo struct {
    Err     error
    Current status.Status
    Message string
    Since   *time.Time
    Version string
    Data    map[string]interface{}
}

StatusInfo holds the unit and machine status information. It is used by ApplicationInfo and UnitInfo.

func NewStatusInfo Uses

func NewStatusInfo(s status.StatusInfo, err error) StatusInfo

NewStatusInfo return a new multiwatcher StatusInfo from a status StatusInfo.

type Store Uses

type Store interface {
    All() []EntityInfo
    // ChangesSince takes revno. A zero implies that this is the first call for changes.
    // A slice of changes is returned along with the latest revno that the store has seen.
    ChangesSince(revno int64) ([]Delta, int64)

    // AddReference and DecReference are used for internal reference counting for the
    // watchers that have been notified.
    // TODO: determine if this is actually useful, and whether this is the right place for it.
    AddReference(revno int64)
    DecReference(revno int64)

    Get(id EntityID) EntityInfo
    Update(info EntityInfo)
    Remove(id EntityID)

    // Size returns the internal size of the store's list.
    // Used only for tests and metrics.
    Size() int
}

Store stores the current entities to use as a basis for the multiwatcher notifications.

func NewStore Uses

func NewStore(logger Logger) Store

NewStore returns an Store instance holding information about the current state of all entities in the model. It is only exposed here for testing purposes.

type UnitInfo Uses

type UnitInfo struct {
    ModelUUID                string
    Name                     string
    Application              string
    Series                   string
    CharmURL                 string
    Life                     life.Value
    Annotations              map[string]string
    PublicAddress            string
    PrivateAddress           string
    MachineID                string
    OpenPortRangesByEndpoint network.GroupedPortRanges
    Principal                string
    Subordinate              bool
    // Workload and agent state are modelled separately.
    WorkloadStatus  StatusInfo
    AgentStatus     StatusInfo
    ContainerStatus StatusInfo // For CAAS models.
}

UnitInfo holds the information about a unit that is tracked by multiwatcherStore.

func (*UnitInfo) Clone Uses

func (i *UnitInfo) Clone() EntityInfo

Clone returns a clone of the EntityInfo.

func (*UnitInfo) EntityID Uses

func (i *UnitInfo) EntityID() EntityID

EntityID returns a unique identifier for a unit across models.

type Watcher Uses

type Watcher interface {
    Stop() error
    Next() ([]Delta, error)
}

Watcher is the way a caller can find out what changes have happened on one or more models.

Package multiwatcher imports 13 packages (graph) and is imported by 20 packages. Updated 2020-09-03. Refresh now. Tools for package owners.