Documentation ¶
Overview ¶
Package leadership provides leadership election and observation.
To participate in leadership election as a candidate, an application must get a candidate implementation from a LeadershipProvider. To observe the quorum, an application must instantiate get an Observer implementation from a LeadershipProvider.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // No leader found. ErrNoLeader = errors.New("no leader found") )
Functions ¶
This section is empty.
Types ¶
type Candidate ¶
type Candidate interface {
// Stop offering candidacy.
Stop()
}
Candidate.
Offers and handles leadership.
type LeadershipHandler ¶
type LeadershipHandler func(end <-chan struct{})
Leadership handler.
Invoked when a candidate becomes a leader. When the leadership ends, an empty struct is sent over end. Returning from the handler function results in termination of the leadership.
type LeadershipProvider ¶
type LeadershipProvider interface { // Get a candidate. GetCandidate(data []byte, leadershipHandler LeadershipHandler) Candidate }
Leadership provider.
func NewZooKeeperLeadershipProvider ¶
func NewZooKeeperLeadershipProvider(connMan *zkutils.ConnMan, path string, acl []zk.ACL) LeadershipProvider
New ZooKeeper leadership provider.
Click to show internal directories.
Click to hide internal directories.