juju: github.com/wallyworld/juju/cmd/jujud/agent/engine Index | Files | Directories

package engine

import "github.com/wallyworld/juju/cmd/jujud/agent/engine"


Package Files

agent.go api.go apiagent.go config.go flag.go housing.go valueworker.go


var EngineErrorDelay = 3 * time.Second

EngineErrorDelay is the amount of time the dependency engine waits between getting an error from a worker, and restarting it. It is exposed here so tests can make it smaller.

func APIManifold Uses

func APIManifold(config APIManifoldConfig, start APIStartFunc) dependency.Manifold

APIManifold returns a dependency.Manifold that calls the supplied start func with the API resource defined in the config (once it's present).

func AgentAPIManifold Uses

func AgentAPIManifold(config AgentAPIManifoldConfig, start AgentAPIStartFunc) dependency.Manifold

AgentAPIManifold returns a dependency.Manifold that calls the supplied start func with the API and agent resources defined in the config (once those resources are present).

func AgentManifold Uses

func AgentManifold(config AgentManifoldConfig, start AgentStartFunc) dependency.Manifold

AgentManifold returns a dependency.Manifold that calls the supplied start func with the agent resource defined in the config (once it's present).

func DependencyEngineConfig Uses

func DependencyEngineConfig() dependency.EngineConfig

DependencyEngineConfig returns a dependency engine config.

func FlagOutput Uses

func FlagOutput(in worker.Worker, out interface{}) error

FlagOutput will expose, as a Flag, any worker that implements Flag.

func NewStaticFlagWorker Uses

func NewStaticFlagWorker(value bool) worker.Worker

NewStaticFlagWorker returns a new Worker that implements Flag, whose Check method always returns the specified value.

func NewValueWorker Uses

func NewValueWorker(value interface{}) (worker.Worker, error)

NewValueWorker returns a degenerate worker that exposes the supplied value when passed into ValueWorkerOutput. Please do not supply values that have their own dependency or lifecycle considerations; such values will subvert the operation of any containing dependency.Engine by insulating it from the failures and dependency changes of the contained value.

func ValueWorkerOutput Uses

func ValueWorkerOutput(in worker.Worker, out interface{}) error

ValueWorkerOutput sets the value wrapped by the supplied valueWorker into the out pointer, if type-compatible, or fails.

type APIManifoldConfig Uses

type APIManifoldConfig struct {
    APICallerName string

Some (hopefully growing number of) manifolds completely depend on an API connection; this type configures them.

type APIStartFunc Uses

type APIStartFunc func(base.APICaller) (worker.Worker, error)

APIStartFunc encapsulates the behaviour that varies among APIManifolds.

type AgentAPIManifoldConfig Uses

type AgentAPIManifoldConfig struct {
    AgentName     string
    APICallerName string

Many manifolds completely depend on an agent and an API connection; this type configures them.

type AgentAPIStartFunc Uses

type AgentAPIStartFunc func(agent.Agent, base.APICaller) (worker.Worker, error)

AgentAPIStartFunc encapsulates the behaviour that varies among AgentAPIManifolds.

type AgentManifoldConfig Uses

type AgentManifoldConfig struct {
    AgentName string

Some manifolds just depend on an agent; this type configures them.

type AgentStartFunc Uses

type AgentStartFunc func(agent.Agent) (worker.Worker, error)

AgentStartFunc encapsulates the behaviour that varies among AgentManifolds.

type Decorator Uses

type Decorator interface {

    // Decorate returns a new Manifold, based on the one supplied.
    Decorate(dependency.Manifold) dependency.Manifold

Decorator creates copies of dependency.Manifolds with additional features.

type Flag Uses

type Flag interface {

    // Check returns the flag's value. Check calls must *always* return
    // the same value for a given instantiation of the type implementing
    // Flag.
    Check() bool

Flag represents a single boolean used to determine whether a given manifold worker should run.

type Housing Uses

type Housing struct {

    // Flags contains a list of names of Flag manifolds, such
    // that a decorated manifold will not start until all flags
    // are both present and valid (and will be stopped when that
    // is no longer true).
    Flags []string

    // Occupy is ignored if empty; otherwise it contains the name
    // of a fortress.Guest manifold, such that a decorated manifold
    // will never be run outside a Visit to that fortress.
    // NOTE: this acquires a lock, and holds it for your manifold's
    // worker's whole lifetime. It's fine in isolation, but multiple
    // Occupy~s are almost certainly a Bad Idea.
    Occupy string

    // Filter is ignored if nil; otherwise it's unconditionally set
    // as the manifold's Filter. Similarly to Occupy, attempted use
    // of multiple filters is unlikely to be a great idea; it most
    // likely indicates that either your Engine's IsFatal is too
    // enthusiastic, or responsibility for termination is spread too
    // widely across your installed manifolds, or both.
    Filter dependency.FilterFunc

Housing is a Decorator that combines several common mechanisms for coordinating manifolds independently of their core concerns.

func (Housing) Decorate Uses

func (housing Housing) Decorate(base dependency.Manifold) dependency.Manifold

Decorate is part of the Decorator interface.



Package engine imports 12 packages (graph). Updated 2020-08-06. Refresh now. Tools for package owners.