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: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClaimDenied = errors.New("leadership claim denied")

ErrClaimDenied is the error which will be returned when a leadership claim has been denied.

Functions

This section is empty.

Types

type LeadershipLeaseManager

type LeadershipLeaseManager interface {
	// Claimlease claims a lease for the given duration for the given
	// namespace and id. If the lease is already owned, a
	// LeaseClaimDeniedErr will be returned. Either way the current lease
	// owner's ID will be returned.
	ClaimLease(namespace, id string, forDur time.Duration) (leaseOwnerId string, err error)

	// ReleaseLease releases the lease held for namespace by id.
	ReleaseLease(namespace, id string) (err error)

	// RetrieveLease retrieves the current lease token for a given
	// namespace. This is not intended to be exposed to clients, and is
	// only available within a server-process.
	RetrieveLease(namespace string) (lease.Token, error)

	// LeaseReleasedNotifier returns a channel a caller can block on to be
	// notified of when a lease is released for namespace. The caller must
	// use a comma-ok to decide whether or not the channel was notified or
	// was closed: if notified, then the lease has been released; if closed,
	// then the lease manager has been disrupted before it could notify
	// the caller.
	LeaseReleasedNotifier(namespace string) (notifier <-chan struct{}, err error)
}

type LeadershipManager

type LeadershipManager interface {
	// ClaimLeadership claims a leadership for the given serviceId and
	// unitId. If successful, the leadership will persist for the supplied
	// duration (or until released).
	ClaimLeadership(serviceId, unitId string, duration time.Duration) error

	// ReleaseLeadership releases a leadership claim for the given
	// serviceId and unitId.
	ReleaseLeadership(serviceId, unitId string) (err error)

	// BlockUntilLeadershipReleased blocks the caller until leadership is
	// released for the given serviceId.
	BlockUntilLeadershipReleased(serviceId string) (err error)
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager represents the business logic for leadership management.

func NewLeadershipManager

func NewLeadershipManager(leaseMgr LeadershipLeaseManager) *Manager

NewLeadershipManager returns a new Manager.

func (*Manager) BlockUntilLeadershipReleased

func (m *Manager) BlockUntilLeadershipReleased(serviceId string) error

BlockUntilLeadershipReleased implements the LeadershipManager interface.

func (*Manager) ClaimLeadership

func (m *Manager) ClaimLeadership(sid, uid string, duration time.Duration) error

ClaimLeadership implements the LeadershipManager interface.

func (*Manager) Leader

func (m *Manager) Leader(sid, uid string) (bool, error)

Leader returns whether or not the given unit id is currently the leader for the given service ID.

func (*Manager) ReleaseLeadership

func (m *Manager) ReleaseLeadership(sid, uid string) error

ReleaseLeadership implements the LeadershipManager interface.

Jump to

Keyboard shortcuts

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