singular

package
v0.0.0-...-8ff1004 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2019 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

Functions

func Manifold

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

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.

Types

type Facade

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

Facade exposes the capabilities required by a FlagWorker.

func NewFacade

func NewFacade(apiCaller base.APICaller, claimant names.MachineTag, 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

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

FlagConfig holds a FlagWorker's dependencies and resources.

func (FlagConfig) Validate

func (config FlagConfig) Validate() error

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

type FlagWorker

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

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

func (*FlagWorker) Check

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

func (flag *FlagWorker) Kill()

Kill is part of the worker.Worker interface.

func (*FlagWorker) Wait

func (flag *FlagWorker) Wait() error

Wait is part of the worker.Worker interface.

type ManifoldConfig

type ManifoldConfig struct {
	ClockName     string
	APICallerName string
	Duration      time.Duration
	Claimant      names.MachineTag
	Entity        names.Tag

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL