election

package
v0.0.0-...-89e5b94 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Elector

type Elector interface {
	IsLeader() bool
	GetLeader() string
	MyIdentity() string
	Run(ctx context.Context)
}

func NewElector

func NewElector(kubeClient kubernetes.Interface, name string, opt ...Option) Elector

type Option

type Option func(*Options)

func WithHealthChecker

func WithHealthChecker(healthChecker *leaderelection.HealthzAdaptor) Option

func WithLockType

func WithLockType(lockType string) Option

func WithNamespace

func WithNamespace(namespace string) Option

func WithOnNewLeader

func WithOnNewLeader(onNewLeader func(string)) Option

func WithOnStartedLeading

func WithOnStartedLeading(onStartedLeading func(context.Context)) Option

func WithOnStoppedLeading

func WithOnStoppedLeading(onStartedLeading func()) Option

type Options

type Options struct {
	Identity      string
	LockType      string
	KubeClient    kubernetes.Interface
	EventRecorder record.EventRecorder
	Namespace     string
	Name          string
	LeaseDuration time.Duration
	RenewDuration time.Duration
	RetryPeriod   time.Duration
	HealthChecker *leaderelection.HealthzAdaptor

	// OnStartedLeading is called when a LeaderElector client starts leading
	OnStartedLeading func(context.Context)
	// OnStoppedLeading is called when a LeaderElector client stops leading
	OnStoppedLeading func()
	// OnNewLeader is called when the client observes a leader that is
	// not the previously observed leader. This includes the first observed
	// leader when the client starts.
	OnNewLeader func(identity string)
}

Jump to

Keyboard shortcuts

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