kubernetes/vendor/go.etcd.io/etcd/client/v3/concurrency/election.go

var ErrElectionNotLeader

var ErrElectionNoLeader

type Election

// NewElection returns a new election on a given key prefix.
func NewElection(s *Session, pfx string) *Election {}

// ResumeElection initializes an election with a known leader.
func ResumeElection(s *Session, pfx string, leaderKey string, leaderRev int64) *Election {}

// Campaign puts a value as eligible for the election on the prefix
// key.
// Multiple sessions can participate in the election for the
// same prefix, but only one can be the leader at a time.
//
// If the context is 'context.TODO()/context.Background()', the Campaign
// will continue to be blocked for other keys to be deleted, unless server
// returns a non-recoverable error (e.g. ErrCompacted).
// Otherwise, until the context is not cancelled or timed-out, Campaign will
// continue to be blocked until it becomes the leader.
func (e *Election) Campaign(ctx context.Context, val string) error {}

// Proclaim lets the leader announce a new value without another election.
func (e *Election) Proclaim(ctx context.Context, val string) error {}

// Resign lets a leader start a new election.
func (e *Election) Resign(ctx context.Context) (err error) {}

// Leader returns the leader value for the current election.
func (e *Election) Leader(ctx context.Context) (*v3.GetResponse, error) {}

// Observe returns a channel that reliably observes ordered leader proposals
// as GetResponse values on every current elected leader key. It will not
// necessarily fetch all historical leader updates, but will always post the
// most recent leader value.
//
// The channel closes when the context is canceled or the underlying watcher
// is otherwise disrupted.
func (e *Election) Observe(ctx context.Context) <-chan v3.GetResponse {}

func (e *Election) observe(ctx context.Context, ch chan<- v3.GetResponse) {}

// Key returns the leader key if elected, empty string otherwise.
func (e *Election) Key() string {}

// Rev returns the leader key's creation revision, if elected.
func (e *Election) Rev() int64 {}

// Header is the response header from the last successful election proposal.
func (e *Election) Header() *pb.ResponseHeader {}