leaderelection

package
v1.2.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, client kubernetes.Interface, config Config, callbacks Callbacks) error

Run runs the leader election with the given callbacks.

Types

type Callbacks

type Callbacks struct {
	// OnStartedLeading is called when this instance becomes the leader.
	OnStartedLeading func(ctx context.Context)

	// OnStoppedLeading is called when this instance loses leadership.
	OnStoppedLeading func()

	// OnNewLeader is called when a new leader is elected.
	OnNewLeader func(identity string)
}

Callbacks defines the callbacks for leader election events.

type Config

type Config struct {
	// Namespace is the namespace for the lease resource.
	Namespace string

	// Name is the name of the lease resource.
	Name string

	// LeaseDuration is the duration of the lease.
	LeaseDuration time.Duration

	// RenewDeadline is the deadline for renewing the lease.
	RenewDeadline time.Duration

	// RetryPeriod is the period between retries.
	RetryPeriod time.Duration
}

Config holds leader election configuration.

Jump to

Keyboard shortcuts

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