lease

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 16 Imported by: 4

Documentation

Index

Constants

View Source
const (
	//NSEnvVar is containing the value of the namespace leases will be managed at, in case it's empty defaultLeaseNs will be used
	NSEnvVar = "LEASE_NAMESPACE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AlreadyHeldError added in v1.2.0

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

AlreadyHeldError is returned in case the lease is already held by a different holder

func (AlreadyHeldError) Error added in v1.2.0

func (e AlreadyHeldError) Error() string

type Manager

type Manager interface {
	//RequestLease will create a lease with leaseDuration if it does not exist or extend existing lease duration to leaseDuration.
	//It'll return an error in case it can't do either (for example if the lease is already taken).
	RequestLease(ctx context.Context, obj client.Object, leaseDuration time.Duration) error
	//InvalidateLease will release the lease.
	InvalidateLease(ctx context.Context, obj client.Object) error
	//GetLease will try to fetch a lease.
	//It'll return an error in case it can't (for example if the lease does not exist or is already taken).
	GetLease(ctx context.Context, obj client.Object) (*coordv1.Lease, error)
}

func NewManager

func NewManager(cl client.Client, holderIdentity string) (Manager, error)

func NewManagerWithCustomLogger

func NewManagerWithCustomLogger(cl client.Client, holderIdentity string, log logr.Logger) (Manager, error)

Jump to

Keyboard shortcuts

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