Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Future ¶
type Future struct {
// contains filtered or unexported fields
}
Future represents a request to acquire leadership that will eventually succeed or fail.
func (*Future) Done ¶
func (f *Future) Done() (*Leadership, error)
Done returns a Leadership object if leadership was acquired withing the timeout, or an error otherwise.
type Leadership ¶
type Leadership struct {
// contains filtered or unexported fields
}
Leadership represents the leadership acquired by a server that was elected as leader. It exposes methods to be notified about its loss, with the server stepping down as leader.
func (*Leadership) Lost ¶
func (l *Leadership) Lost() chan struct{}
Lost returns a channel that gets closed when leadership is lost.
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker consumes the raft.Config.NotifyCh set on each server of a cluster, tracking when elections occur.
func NewTracker ¶
func NewTracker(logger hclog.Logger) *Tracker
NewTracker creates a new Tracker for watching leadership changes in a raft cluster.
func (*Tracker) Close ¶
func (t *Tracker) Close()
Close stops watching for leadership changes in the cluster.
func (*Tracker) Expect ¶
Expect returns an election Future object whose Done() method will return a Leadership object when the server with the given ID acquires leadership, or an error if the given timeout expires.
It must be called before this server has any chance to become leader (e.g. it's disconnected from the other servers).
Once called, it must not be called again until leadership is lost.