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

package presence

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

The presence package works on the premise that an agent it alive if it has a current connection to one of the API servers.

This package handles all of the logic around collecting an organising the information around all the connections made to the API servers.

Index

Package Files

presence.go

type Clock Uses

type Clock interface {
    // Now returns the current clock time.
    Now() time.Time
}

Clock provides an interface for dealing with clocks.

type Connections Uses

type Connections interface {
    // ForModel will return the connections just for the specified model UUID.
    ForModel(model string) Connections

    // ForServer will return just the connections for agents connected to the specified
    // server. The server is a stringified machine tag for the API server.
    ForServer(server string) Connections

    // ForAgent returns the connections for the specified agent in the model.
    // The agent is the stringified machine or unit tag.
    ForAgent(agent string) Connections

    // Count returns the number of connections.
    Count() int

    // Models returns all the model UUIDs that have connections.
    Models() []string

    // Servers returns all the API servers that have connections in this
    // collection.
    Servers() []string

    // Agents returns all the stringified agent tags that have connections
    // in this collection.
    Agents() []string

    // For a given non controller agent, return the Status for that agent.
    AgentStatus(agent string) (Status, error)

    // Values returns the connection information for this collection.
    Values() []Value
}

Connections provides a way to slice the full presence understanding across various axis like server, model and agent.

type Recorder Uses

type Recorder interface {
    // Disable clears the entries and marks the recorder as disabled. Note
    // that all agents will have a recorder, but they are only enabled for
    // API server agents.
    Disable()

    // Enable marks the recorder as enabled.
    Enable()

    // IsEnabled returns whether or not the recorder is enabled.
    IsEnabled() bool

    // Connect adds an entry for the specified agent.
    // The server and agent strings are the stringified machine and unit tags.
    // The model is the UUID for the model.
    Connect(server, model, agent string, id uint64, controllerAgent bool, userData string)

    // Disconnect removes the entry for the specified connection id.
    Disconnect(server string, id uint64)

    // Activity updates the last seen timestamp for the connection specified.
    Activity(server string, id uint64)

    // ServerDown marks all connections on the specified server as unknown.
    ServerDown(server string)

    // UpdateServer replaces all known connections for the specified server
    // with the connections specified. If any of the connections are not for
    // the specified server, an error is returned.
    UpdateServer(server string, connections []Value) error

    // Connections returns all connections info that the recorder has.
    Connections() Connections
}

Recorder records the presence status of every apiserver connection for the agents.

func New Uses

func New(clock Clock) Recorder

New returns a new empty Recorder.

type Status Uses

type Status int

Status represents the state of a given agent's presence.

const (
    // Unknown means that the agent specified is not in the collection.
    Unknown Status = iota

    // Missing means that the agent was connected, but the server that it was
    // connected to has gone away and not yet come back.
    Missing

    // Alive means that the connection is active.
    Alive
)

func (Status) String Uses

func (s Status) String() string

String implements Stringer.

type Value Uses

type Value struct {
    // Model is the model UUID.
    Model string

    // Server is the stringified machine tag of the API server.
    Server string

    // Agent is the stringified machine, unit, or application tag of the agent.
    Agent string

    // ControllerAgent is true if the agent is in the controller model.
    ControllerAgent bool

    // ConnectionID is the unique identifier given by the API server.
    ConnectionID uint64

    // Status is either Missing or Alive.
    Status Status

    // UserData is the user data provided with the Login API call.
    UserData string

    // LastSeen is the timestamp when the connection was added using
    // Connect, or the last time Activity was called.
    LastSeen time.Time
}

Value holds the information about a single agent connection to an apiserver machine.

Package presence imports 4 packages (graph) and is imported by 36 packages. Updated 2018-10-03. Refresh now. Tools for package owners.