Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager interface { // ClaimLeadership claims leadership of the named service on behalf of the // named unit. If no error is returned, leadership will be guaranteed for // at least the supplied duration from the point when the call was made. ClaimLeadership(serviceName, unitName string, duration time.Duration) error // CheckLeadership verifies that the named unit is leader of the named // service, and returns a Token attesting to that fact for use building // mgo/txn transactions that depend upon it. CheckLeadership(serviceName, unitName string) (Token, error) // BlockUntilLeadershipReleased blocks until the named service is known // to have no leader, in which case it returns no error; or until the // manager is stopped, in which case it will fail. BlockUntilLeadershipReleased(serviceName string) error }
Manager allows units to claim service leadership; to verify a unit's continued leadership of a service; and to wait until a service has no leader.
type ManagerConfig ¶
ManagerConfig contains the resources and information required to create a Manager.
func (ManagerConfig) Validate ¶
func (config ManagerConfig) Validate() error
Validate returns an error if the configuration contains invalid information or missing resources.
type ManagerWorker ¶
ManagerWorker implements Manager and worker.Worker.
func NewManager ¶
func NewManager(config ManagerConfig) (ManagerWorker, error)
NewManager returns a Manager implementation, backed by a lease.Client, which (in addition to its exposed Manager capabilities) will expire all known leases as they run out. The caller takes responsibility for killing, and handling errors from, the returned Worker.
type Token ¶
type Token interface { // AssertOps returns mgo/txn operations that will abort if some fact no // longer holds true. AssertOps() []txn.Op }
Token exposes mgo/txn operations that can be added to a transaction in order to abort it if the check that generated the Token would no longer pass.