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

package lifeflag

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

Index

Package Files

manifold.go shim.go worker.go

Variables

var (
    // ErrNotFound indicates that the worker cannot run because
    // the configured entity does not exist.
    ErrNotFound = errors.New("entity not found")

    // ErrValueChanged indicates that the result of Check is
    // outdated, and the worker should be restarted.
    ErrValueChanged = errors.New("flag value changed")
)

func Manifold Uses

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency.Manifold that will run a Worker as configured.

func NewWorker Uses

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

type Config Uses

type Config struct {
    Facade Facade
    Entity names.Tag
    Result life.Predicate
}

Config holds the configuration and dependencies for a worker.

func (Config) Validate Uses

func (config Config) Validate() error

Validate returns an error if the config cannot be expected to drive a functional worker.

type Facade Uses

type Facade interface {
    Watch(names.Tag) (watcher.NotifyWatcher, error)
    Life(names.Tag) (life.Value, error)
}

Facade exposes capabilities required by the worker.

func NewFacade Uses

func NewFacade(apiCaller base.APICaller) (Facade, error)

type ManifoldConfig Uses

type ManifoldConfig struct {
    APICallerName string
    Entity        names.Tag
    Result        life.Predicate
    Filter        dependency.FilterFunc

    NewFacade func(base.APICaller) (Facade, error)
    NewWorker func(Config) (worker.Worker, error)
}

ManifoldConfig describes how to configure and construct a Worker, and what registered resources it may depend upon.

type Worker Uses

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

Worker holds the result of some predicate regarding an entity's life, and fails with ErrValueChanged when the result of the predicate changes.

func New Uses

func New(config Config) (*Worker, error)

New returns a worker that exposes the result of the configured predicate when applied to the configured entity's life value, and fails with ErrValueChanged when the result changes.

func (*Worker) Check Uses

func (w *Worker) Check() bool

Check is part of the util.Flag interface.

func (*Worker) Kill Uses

func (w *Worker) Kill()

Kill is part of the worker.Worker interface.

func (*Worker) Wait Uses

func (w *Worker) Wait() error

Wait is part of the worker.Worker interface.

Package lifeflag imports 11 packages (graph) and is imported by 23 packages. Updated 2019-10-13. Refresh now. Tools for package owners.