Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDisabled ¶ added in v1.12.32
func IsDisabled() bool
IsDisabled returns true if leader election is disabled using an environment variable
func NewIdentity ¶
func NewIdentity(elected <-chan struct{}) *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 // Elected returns the channel that will be signaled when the current component is elected the leader Elected() <-chan struct{} }
Identity contains leader election information about the current component
type LeaderStartupAction ¶ added in v1.12.28
type LeaderStartupAction struct {
// contains filtered or unexported fields
}
func NewLeaderStartupAction ¶ added in v1.12.28
func NewLeaderStartupAction(identity Identity) *LeaderStartupAction
func (*LeaderStartupAction) GetAction ¶ added in v1.12.28
func (a *LeaderStartupAction) GetAction() func() error
func (*LeaderStartupAction) SetAction ¶ added in v1.12.28
func (a *LeaderStartupAction) SetAction(action func() error)
func (*LeaderStartupAction) WatchElectionResults ¶ added in v1.12.28
func (a *LeaderStartupAction) WatchElectionResults(ctx context.Context)
Click to show internal directories.
Click to hide internal directories.