leaderelection

package
v0.0.0-...-d7ce96e Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2020 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callbacks

type Callbacks struct {
	// OnStartedLeading is called when a LeaderElector client starts leading
	OnStartedLeading func(context.Context)
	// OnStoppedLeading is called when a LeaderElector client stops leading. Actually it is called when every member dies.
	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)
}

type Config

type Config struct {
	// MemberID is the identifier of the member for leader election
	MemberID string
	// LeaseDuration is the duration that non-leader candidates will
	// wait to force acquire leadership. This is measured against time of
	// last observed ack.
	LeaseDuration time.Duration
	// RenewDeadline is the duration that the acting master will retry
	// refreshing leadership before giving up.
	RenewDeadline time.Duration
	// RetryPeriod is the duration the LeaderElector clients should wait
	// between tries of actions.
	RetryPeriod time.Duration
	// ComponentName is used as the group name for this leader election group. If you run
	// multiple leader elector instances within a service you probably want to differentiate
	// them by name.
	ComponentName string
	// LeaseLockName is name of the lease resource lock that is used for leader election.
	// You probably don't ever need to set this.
	LeaseLockName string
	// LeaseLockNamespace is the namespace of the lease resource lock
	LeaseLockNamespace string
	// The address of the Kubernetes API server (overrides any value in kubeconfig)
	KubeMaster string
	// Path to kubeconfig. If left unset the in cluster config is used by default.
	KubeConfig string
	// Callbacks are callbacks that are triggered during certain lifecycle
	// events of the LeaderElector
	Callbacks Callbacks
}

type Election

type Election struct {
	// contains filtered or unexported fields
}

func NewElection

func NewElection(config *Config) (*Election, error)

func NewElectionWithKubeConfig

func NewElectionWithKubeConfig(config *Config, kubeConfig *rest.Config) (*Election, error)

func (*Election) IsLeader

func (e *Election) IsLeader() bool

func (*Election) Run

func (e *Election) Run(ctx context.Context)

Jump to

Keyboard shortcuts

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