Documentation
¶
Index ¶
- func LeaseName(key ResourceKey) string
- type ErrAlreadyLocked
- type ErrLockExpired
- type LeaseManager
- func (m *LeaseManager) Acquire(ctx context.Context, key ResourceKey, txnName string, timeout time.Duration) (string, error)
- func (m *LeaseManager) Release(ctx context.Context, lease LeaseRef, txnName string) error
- func (m *LeaseManager) ReleaseAll(ctx context.Context, leases []LeaseRef, txnName string) error
- func (m *LeaseManager) Renew(ctx context.Context, lease LeaseRef, txnName string, timeout time.Duration) error
- type LeaseOpError
- type LeaseRef
- type Manager
- type ResourceKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LeaseName ¶
func LeaseName(key ResourceKey) string
LeaseName returns the deterministic lease name for a resource.
Types ¶
type ErrAlreadyLocked ¶
ErrAlreadyLocked indicates that a resource is locked by a different transaction.
func (*ErrAlreadyLocked) Error ¶
func (e *ErrAlreadyLocked) Error() string
type ErrLockExpired ¶
type ErrLockExpired struct {
LeaseName string
}
ErrLockExpired indicates that a lock lease has expired.
func (*ErrLockExpired) Error ¶
func (e *ErrLockExpired) Error() string
type LeaseManager ¶
LeaseManager implements Manager using coordination.k8s.io/v1 Lease objects.
func (*LeaseManager) Acquire ¶
func (m *LeaseManager) Acquire(ctx context.Context, key ResourceKey, txnName string, timeout time.Duration) (string, error)
func (*LeaseManager) ReleaseAll ¶
type LeaseOpError ¶
type LeaseOpError struct {
Op string // e.g. "creating", "getting", "deleting", "renewing", "taking over"
LeaseName string
Err error
}
LeaseOpError wraps a Kubernetes API error with lease operation context.
func (*LeaseOpError) Error ¶
func (e *LeaseOpError) Error() string
func (*LeaseOpError) Unwrap ¶
func (e *LeaseOpError) Unwrap() error
type Manager ¶
type Manager interface {
// Acquire creates or takes over a Lease lock for the given resource.
// Returns the lease name on success.
Acquire(ctx context.Context, key ResourceKey, txnName string, timeout time.Duration) (string, error)
// Release deletes a single Lease lock if held by the given transaction.
// If the lease is held by a different transaction, the call is a no-op.
Release(ctx context.Context, lease LeaseRef, txnName string) error
// ReleaseAll releases multiple leases, returning the first error encountered.
ReleaseAll(ctx context.Context, leases []LeaseRef, txnName string) error
// Renew extends the lease duration for a lock held by the given transaction.
// Returns an error if the lease is not found, expired, or held by a different transaction.
Renew(ctx context.Context, lease LeaseRef, txnName string, timeout time.Duration) error
}
Manager manages Lease-based advisory locks for transaction resources.
type ResourceKey ¶
ResourceKey identifies a Kubernetes resource for locking purposes.
Click to show internal directories.
Click to hide internal directories.