leaderelector

package
v1.12.9 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIdentity

func NewIdentity(leaderValue *atomic.Bool) *identityImpl

Types

type ElectionConfig

type ElectionConfig struct {
	// The name of the component
	Id string
	// The namespace where the component is running
	Namespace string
	// Callback function that is executed when the current component becomes leader
	OnStartedLeading func(c context.Context)
	// Callback function that is executed when the current component stops leading
	OnStoppedLeading func()
	// Callback function that is executed when a new leader is elected
	OnNewLeader func(leaderId string)
}

ElectionConfig is the set of properties that can be used to configure leader elections

type ElectionFactory

type ElectionFactory interface {
	// StartElection begins leader election and returns the Identity of the current component
	StartElection(ctx context.Context, config *ElectionConfig) (Identity, error)
}

An ElectionFactory is an implementation for running a leader election

type Identity

type Identity interface {
	// IsLeader returns true if the current component is the leader, false otherwise
	IsLeader() bool
}

Identity contains leader election information about the current component

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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