election

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FxTagBase is the tag's base used to identify the election result Tracker.
	FxTagBase = "etcd_election"
	// FxTag is the tag used to identify the election result Tracker.
	FxTag = config.NameTag(FxTagBase)
	// ElectionResultKey is the key used to identify the election result in the election Tracker.
	ElectionResultKey = notifiers.Key("election_result")
)

Functions

func Module

func Module() fx.Option

Module is a fx module that provides etcd based leader election per agent group.

Types

type Election

type Election struct {
	Election *concurrencyv3.Election
	// contains filtered or unexported fields
}

Election is a wrapper around etcd election.

func ProvideElection

func ProvideElection(in ElectionIn) (*Election, error)

ProvideElection provides a wrapper around etcd based leader election.

func (*Election) Done added in v1.2.0

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
	Client     *etcd.Client
	AgentInfo  *agentinfo.AgentInfo
	Trackers   notifiers.Trackers `name:"etcd_election"`
}

ElectionIn holds parameters for ProvideElection.

Jump to

Keyboard shortcuts

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