election

package
v0.0.0-...-ecdf110 Latest Latest
Warning

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

Go to latest
Published: May 20, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

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

func (t *Tracker) Expect(id raft.ServerID, timeout time.Duration) *Future

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.

func (*Tracker) Ignore

func (t *Tracker) Ignore()

Ignore stops propagating leadership change notifications, which will be simply dropped on the floor. Should be called before the final Close().

func (*Tracker) Track

func (t *Tracker) Track(id raft.ServerID, notifyCh chan bool)

Track leadership changes on the server with the given ID using the given Config.NotifyCh.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL