leaderelection

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package leaderelection contains the leader election mechanism.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blocking

func Blocking(ctx context.Context, rc *rest.Config, eb record.EventBroadcaster, opts *Opts) (bool, error)

Blocking runs the blocking leader election.

func Init

Init initializes the leader election mechanism.

func IsLeader

func IsLeader() bool

IsLeader returns true if the current pod is the leader.

func LabelerOnElection

func LabelerOnElection(ctx context.Context, mgr manager.Manager, info *PodInfo)

LabelerOnElection is a function that labels the leader pod with the leader label.

func Run

func Run(ctx context.Context, leaderelector *leaderelection.LeaderElector)

Run run the leader election mechanism.

Types

type Opts

type Opts struct {
	PodInfo
	Client            client.Client
	LeaderElectorName string
	LeaseDuration     time.Duration
	RenewDeadline     time.Duration
	RetryPeriod       time.Duration
	InitCallback      func()
	StopCallback      func()
	LabelLeader       bool
}

Opts contains the options to configure the leader election mechanism.

type PodInfo

type PodInfo struct {
	PodName        string
	Namespace      string
	DeploymentName *string
}

PodInfo contains the information about the pod.

Jump to

Keyboard shortcuts

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