lease

package
v0.10.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lease

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

Lease implements a lease on time ranges for different backends. If the lease backend has intermittent failure, the lease will attempt to gracefully fail open by extending the lease of the most recent lease holder. This is done in best-effort manner.

func New

func New(
	logger log.Logger,
	metrics prometheus.Registerer,
	lock resourcelock.Interface,
	opts *Options,
) (*Lease, error)

func NewKubernetes

func NewKubernetes(
	logger log.Logger,
	metrics prometheus.Registerer,
	config *rest.Config,
	namespace, name string,
	opts *Options,
) (*Lease, error)

func (*Lease) OnLeaderChange

func (l *Lease) OnLeaderChange(f func())

OnLeaderChange sets a callback that's invoked when the leader of the lease changes.

func (*Lease) Range

func (l *Lease) Range() (start, end time.Time, ok bool)

func (*Lease) Run

func (l *Lease) Run(ctx context.Context)

Run starts trying to acquire and hold the lease until the context is canceled.

type Options

type Options struct {
	// LeaseDuration is the duration that non-leader candidates will
	// wait to force acquire leadership. This is measured against time of
	// last observed ack.
	//
	// A client needs to wait a full LeaseDuration without observing a change to
	// the record before it can attempt to take over. When all clients are
	// shutdown and a new set of clients are started with different names against
	// the same leader record, they must wait the full LeaseDuration before
	// attempting to acquire the lease. Thus LeaseDuration should be as short as
	// possible (within your tolerance for clock skew rate) to avoid a possible
	// long waits in the scenario.
	//
	// Defaults to 15 seconds.
	LeaseDuration time.Duration
	// RenewDeadline is the duration that the acting master will retry
	// refreshing leadership before giving up.
	//
	// Defaults to 10 seconds.
	RenewDeadline time.Duration
	// RetryPeriod is the duration the LeaderElector clients should wait
	// between tries of actions.
	//
	// Defaults to 2 seconds.
	RetryPeriod time.Duration
}

Jump to

Keyboard shortcuts

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