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.
var PingInterval = 10 * time.Second
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 New ¶
New returns a Runner that can be used to start workers that will only run a single instance. The conn value is used to determine whether to run the workers or not.
If conn.IsMaster returns true, any workers started will be started on the underlying runner.
If conn.IsMaster returns false, any workers started will actually start do-nothing placeholder workers on the underlying runner that continually ping the connection until a ping fails and then exit with that error.
Types ¶
type Conn ¶
type Conn interface { // IsMaster reports whether this connection is currently held by // the (singular) master of the resource. IsMaster() (bool, error) // Ping probes the resource and returns an error if the the // connection has failed. If the master changes, this method // must return an error. Ping() error }
Conn represents a connection to some resource.
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 AgentName string Duration time.Duration NewFacade func(base.APICaller, names.MachineTag) (Facade, error) NewWorker func(FlagConfig) (worker.Worker, error) }
ManifoldConfig holds the information necessary to run a FlagWorker in a dependency.Engine.