leadership

package
v0.0.0-...-f19ae85 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

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

LeadershipClaimDeniedErr 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

	// LeaseReleasedNotifier returns a channel a caller can block on to be
	// notified of when a lease is released for namespace. This channel is
	// reusable, but will be closed if it does not respond within
	// "notificationTimeout".
	LeaseReleasedNotifier(namespace string) (notifier <-chan struct{})
}

type LeadershipManager

type LeadershipManager interface {
	// ClaimLeadership claims a leadership for the given serviceId and
	// unitId. If successful, the duration of the leadership lease is
	// returned.
	ClaimLeadership(serviceId, unitId string) (nextClaimInterval time.Duration, err 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) (time.Duration, error)

ClaimLeadership implements the LeadershipManager interface.

func (*Manager) Leader

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

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