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 ¶
BlockUntilLeadershipReleased implements the LeadershipManager interface.
func (*Manager) ClaimLeadership ¶
ClaimLeadership implements the LeadershipManager interface.
func (*Manager) Leader ¶
Leader returns whether or not the given unit id is currently the leader for the given service ID.
func (*Manager) ReleaseLeadership ¶
ReleaseLeadership implements the LeadershipManager interface.
Click to show internal directories.
Click to hide internal directories.