juju: github.com/juju/juju/worker/singular Index | Files

package singular

import "github.com/juju/juju/worker/singular"

Index

Package Files

flag.go manifold.go shim.go

Variables

var ErrRefresh = errors.New("model responsibility unclear, please retry")

ErrRefresh indicates that the flag's Check result is no longer valid, and a new FlagWorker must be started to get a valid result.

func Manifold Uses

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency.Manifold that will run a FlagWorker and expose it to clients as a engine.Flag resource.

func NewWorker Uses

func NewWorker(config FlagConfig) (worker.Worker, error)

NewWorker calls NewFlagWorker but returns a more convenient type. It's a suitable default value for ManifoldConfig.NewWorker.

type Facade Uses

type Facade interface {
    Claim(duration time.Duration) error
    Wait() error
}

Facade exposes the capabilities required by a FlagWorker.

func NewFacade Uses

func NewFacade(apiCaller base.APICaller, claimant names.Tag, entity names.Tag) (Facade, error)

NewFacade creates a Facade from an APICaller and an entity for which administrative control will be claimed. It's a suitable default value for ManifoldConfig.NewFacade.

type FlagConfig Uses

type FlagConfig struct {
    Clock    clock.Clock
    Facade   Facade
    Duration time.Duration
}

FlagConfig holds a FlagWorker's dependencies and resources.

func (FlagConfig) Validate Uses

func (config FlagConfig) Validate() error

Validate returns an error if the config cannot be expected to run a FlagWorker.

type FlagWorker Uses

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

FlagWorker implements worker.Worker and util.Flag, representing controller ownership of a model, such that the Flag's validity is tied to the Worker's lifetime.

func NewFlagWorker Uses

func NewFlagWorker(config FlagConfig) (*FlagWorker, error)

func (*FlagWorker) Check Uses

func (flag *FlagWorker) Check() bool

Check is part of the util.Flag interface.

Check returns true if the flag indicates that the configured Identity (i.e. this controller) has taken control of the configured Scope (i.e. the model we want to manage exclusively).

The validity of this result is tied to the lifetime of the FlagWorker; once the worker has stopped, no inferences may be drawn from any Check result.

func (*FlagWorker) Kill Uses

func (flag *FlagWorker) Kill()

Kill is part of the worker.Worker interface.

func (*FlagWorker) Wait Uses

func (flag *FlagWorker) Wait() error

Wait is part of the worker.Worker interface.

type ManifoldConfig Uses

type ManifoldConfig struct {
    Clock         clock.Clock
    APICallerName string
    Duration      time.Duration
    // TODO(controlleragent) - claimaint should be a ControllerAgentTag
    Claimant names.Tag
    Entity   names.Tag

    NewFacade func(base.APICaller, names.Tag, names.Tag) (Facade, error)
    NewWorker func(FlagConfig) (worker.Worker, error)
}

ManifoldConfig holds the information necessary to run a FlagWorker in a dependency.Engine.

func (*ManifoldConfig) Validate Uses

func (config *ManifoldConfig) Validate() error

Validate ensures the required values are set.

Package singular imports 11 packages (graph) and is imported by 64 packages. Updated 2019-10-20. Refresh now. Tools for package owners.