Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NewManifoldWorker = func(agent agent.Agent, apiCaller base.APICaller, clock clock.Clock, guarantee time.Duration) (worker.Worker, error) { tag := agent.CurrentConfig().Tag() unitTag, ok := tag.(names.UnitTag) if !ok { return nil, fmt.Errorf("expected a unit tag; got %q", tag) } claimer := leadership.NewClient(apiCaller) return NewTracker(unitTag, claimer, clock, guarantee), nil }
NewManifoldWorker wraps NewTracker for the convenience of startFunc. It exists primarily to be patched out via NewManifoldWorker for ease of testing, and is not itself directly tested. It would almost certainly be better to pass the constructor dependencies in as explicit manifold config.
Functions ¶
func Manifold ¶
func Manifold(config ManifoldConfig) dependency.Manifold
Manifold returns a manifold whose worker wraps a Tracker working on behalf of the dependency identified by AgentName.
Types ¶
type ManifoldConfig ¶
type ManifoldConfig struct { AgentName string APICallerName string Clock clock.Clock LeadershipGuarantee time.Duration }
ManifoldConfig defines the names of the manifolds on which a Manifold will depend.
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
func NewTracker ¶
func NewTracker(tag names.UnitTag, claimer leadership.Claimer, clock clock.Clock, duration time.Duration) *Tracker
NewTracker returns a *Tracker that attempts to claim and retain application leadership for the supplied unit. It will claim leadership for twice the supplied duration, and once it's leader it will renew leadership every time the duration elapses. Thus, successful leadership claims on the resulting Tracker will guarantee leadership for the duration supplied here without generating additional calls to the supplied manager (which may very well be on the other side of a network connection).
func (*Tracker) ApplicationName ¶
ApplicationName is part of the leadership.Tracker interface.
func (*Tracker) ClaimDuration ¶
ClaimDuration is part of the leadership.Tracker interface.
func (*Tracker) ClaimLeader ¶
func (t *Tracker) ClaimLeader() leadership.Ticket
ClaimLeader is part of the leadership.Tracker interface.
func (*Tracker) WaitLeader ¶
func (t *Tracker) WaitLeader() leadership.Ticket
WaitLeader is part of the leadership.Tracker interface.
func (*Tracker) WaitMinion ¶
func (t *Tracker) WaitMinion() leadership.Ticket
WaitMinion is part of the leadership.Tracker interface.