leadership

package
v0.0.0-...-be26699 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2015 License: AGPL-3.0 Imports: 10 Imported by: 0

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

type ManagerConfig struct {
	Client lease.Client
	Clock  lease.Clock
}

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

type ManagerWorker interface {
	worker.Worker
	Manager
}

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.

Jump to

Keyboard shortcuts

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