Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrConflict = errors.New("lease already held")
ErrConflict is returned when a lease is already held.
Functions ¶
This section is empty.
Types ¶
type FakeLeaser ¶
type FakeLeaser struct {
// contains filtered or unexported fields
}
FakeLeaser is a fake implementation of the Leaser interface.
func NewFakeLeaser ¶
func NewFakeLeaser() *FakeLeaser
func (*FakeLeaser) AcquireLease ¶
func (*FakeLeaser) GetLeaseInfo ¶ added in v0.263.0
type Key ¶
type Key []string
Key is a unique identifier for a lease.
It is a / separated list of strings where each element is URL-path-escaped.
Userspace leases are always in the form "/module/<module>/..." (eg. "/module/idv/user/bob"). Internal leases are always in the form "/system/..." (eg. "/system/runner/deployment-reservation/<deployment").
Keys should always be created using the SystemKey or ModuleKey functions.
func ParseLeaseKey ¶
type Lease ¶
type Lease interface {
Release() error
}
Lease represents a lease that is held by a controller.
type Leaser ¶
type Leaser interface { // AcquireLease attempts to acquire a new lease. // // A lease is a mechanism to ensure that only one controller is performing a // specific task at a time. The lease is held for a specific duration, and must // be renewed periodically to prevent it from expiring. If the lease expires, it // is released and another controller can acquire it. // // The lease is automatically renewed in the background, and can be // released by calling the [Lease.Release] method. // // This function will return [ErrConflict] if a lease is already held. The [ttl] // must be at _least_ 5 seconds. // // The returned context will be cancelled when the lease fails to renew. AcquireLease(ctx context.Context, key Key, ttl time.Duration, metadata optional.Option[any]) (Lease, context.Context, error) // GetLeaseInfo returns the metadata and expiry time for a key. // // metadata should be a pointer to the type that metadata should be unmarshaled into. GetLeaseInfo(ctx context.Context, key Key, metadata any) (expiry time.Time, err error) }
Leaser is an interface for acquiring, renewing and releasing leases.
Click to show internal directories.
Click to hide internal directories.