Documentation ¶
Index ¶
Constants ¶
const ( StateUnknown = iota StateFollower StateLeader )
Possible values for ElectionState.State.
Variables ¶
This section is empty.
Functions ¶
func Observe ¶
func Observe(ctx context.Context, session *concurrency.Session, path string) <-chan ElectionState
Observe an election without participating in it. It's a simple way to track the current leader.
func WaitForever ¶
WaitForever is an Op that does nothing (until the Context is canceled).
Types ¶
type Election ¶
type Election struct {
// contains filtered or unexported fields
}
Election manages (or witnesses) an election protocol on a given database prefix.
func New ¶
New creates a new Election, scoped within the provided session. If self is not nil, the caller participates in the election and can call Run().
type ElectionState ¶
ElectionState represents the current state of the election, with the value of the current leader endpoint, if any.
func (ElectionState) String ¶
func (s ElectionState) String() string
type ElectionWatcher ¶
type ElectionWatcher struct {
// contains filtered or unexported fields
}
An ElectionWatcher simply consumes the output of Election.Watch and stores the most recent result so you can query it asynchronously.
func NewWatcher ¶
func NewWatcher(ctx context.Context, el *Election) *ElectionWatcher
NewWatcher creates a new ElectionWatcher.
func (*ElectionWatcher) Notify ¶
func (w *ElectionWatcher) Notify() <-chan struct{}
Notify returns a channel that is triggered on every state change.
func (*ElectionWatcher) State ¶
func (w *ElectionWatcher) State() ElectionState
State returns the most recent ElectionState.