lease

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewResourceLock

func NewResourceLock(config *rest.Config, eventRecorder resourcelock.EventRecorder, options Options) (resourcelock.Interface, error)

NewResourceLock returns a new resource lock that implements the shard lease. Pass this to the leader elector, e.g., leaderelection.LeaderElectionConfig.Lock (if using plain client-go) or manager.Options.LeaderElectionResourceLockInterface (if using controller-runtime).

Types

type LeaseLock

type LeaseLock struct {
	// LeaseMeta should contain a Name and a Namespace of a
	// LeaseMeta object that the LeaderElector will attempt to lead.
	LeaseMeta  metav1.ObjectMeta
	Client     coordinationv1client.LeasesGetter
	LockConfig resourcelock.ResourceLockConfig
	Labels     map[string]string
	// contains filtered or unexported fields
}

LeaseLock implements resourcelock.Interface but is able to add labels to the Lease. The implementation is based resourclock.LeaseLock and shares some helper functions with it. nolint:revive // don't rename LeaseLock to stay close to the original implementation in client-go.

func (*LeaseLock) Create

Create attempts to create a Lease

func (*LeaseLock) Describe

func (ll *LeaseLock) Describe() string

Describe is used to convert details on current resource lock into a string

func (*LeaseLock) Get

Get returns the election record from a Lease spec

func (*LeaseLock) Identity

func (ll *LeaseLock) Identity() string

Identity returns the Identity of the lock

func (*LeaseLock) RecordEvent

func (ll *LeaseLock) RecordEvent(s string)

RecordEvent in leader election while adding meta-data

func (*LeaseLock) Update

Update will update an existing Lease spec.

type Options

type Options struct {
	// ClusterRingName specifies the name of the ClusterRing that the shard belongs to.
	ClusterRingName string
	// LeaseNamespace determines the namespace in which the shard lease will be created.
	// Defaults to the pod's namespace if running in-cluster.
	LeaseNamespace string
	// ShardName determines the name of the shard. This will be used as the lease name as well as the lease's
	// holderIdentity.
	// Defaults to os.Hostname().
	ShardName string
}

Options provides the required configuration to create a new shard lease.

Jump to

Keyboard shortcuts

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