Documentation ¶
Index ¶
Constants ¶
This section is empty.
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.
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 FlagConfig ¶
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.