election

package
v2.21.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Election

type Election struct {
	// contains filtered or unexported fields
}

Election is a wrapper around etcd election.

func ProvideElection

func ProvideElection(key string, in ElectionIn) *Election

ProvideElection provides a wrapper around etcd based leader election for arbitrary key.

Note: This is not exposed directly by any module – controller and agent have their own leader election fx Options.

func (*Election) Done

func (e *Election) Done() <-chan struct{}

Done returns a channel that could be used to wait for election results.

When the channel is closed then either: * Node became a leader (IsLeader() == true), * Leader election was canceled (IsLeader() == false).

func (*Election) IsLeader

func (e *Election) IsLeader() bool

IsLeader returns true if the current node is the leader.

type ElectionIn

type ElectionIn struct {
	fx.In
	Lifecycle  fx.Lifecycle
	Shutdowner fx.Shutdowner
	Session    *etcd.Session
}

ElectionIn holds parameters for ProvideElection.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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