Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrLockAlreadyLeased = default_errors.New("lock already leased") ErrNoExistingLockLeaseFound = default_errors.New("no existing lock lease found") )
Functions ¶
func WithAcquire ¶
Types ¶
type AcquireOptions ¶
type AcquireOptions struct {
NonBlocking bool
Timeout time.Duration
OnWaitFunc func(lock LockHandle, doWait func() error) error
OnLostLeaseFunc func(lock LockHandle) error
}
type FileLocker ¶
type FileLocker struct {
LocksDir string
// contains filtered or unexported fields
}
func NewFileLocker ¶
func NewFileLocker(locksDir string) (*FileLocker, error)
func (*FileLocker) Acquire ¶
func (locker *FileLocker) Acquire(lockName string, opts AcquireOptions) (bool, LockHandle, error)
func (*FileLocker) Release ¶
func (locker *FileLocker) Release(lockHandle LockHandle) error
type KubernetesLocker ¶
type KubernetesLocker struct {
KubernetesInterface dynamic.Interface
GVR schema.GroupVersionResource
ResourceName string
Namespace string
// contains filtered or unexported fields
}
func NewKubernetesLocker ¶
func NewKubernetesLocker(kubernetesInterface dynamic.Interface, gvr schema.GroupVersionResource, resourceName string, namespace string) *KubernetesLocker
func (*KubernetesLocker) Acquire ¶
func (locker *KubernetesLocker) Acquire(lockName string, opts AcquireOptions) (bool, LockHandle, error)
func (*KubernetesLocker) Release ¶
func (locker *KubernetesLocker) Release(lockHandle LockHandle) error
type LeaseRenewWorkerDescriptor ¶
type LeaseRenewWorkerDescriptor struct {
DoneChan chan struct{}
}
type LockHandle ¶
type LockLeaseRecord ¶
type LockLeaseRecord struct {
LockHandle
ExpireAtTimestamp int64
}
type Locker ¶
type Locker interface {
Acquire(lockName string, opts AcquireOptions) (bool, LockHandle, error)
Release(lock LockHandle) error
}
Locker is an abstract interface to interact with the locker. Locker implementation is always thread safe so it is possible to use a single Locker in multiple goroutines.
Note that LockHandle objects should be managed by the user manually to acquire multiple locks from the same process: to release a lock user must pass the same LockHandle object that was given by Acquire method to the Release method.
Click to show internal directories.
Click to hide internal directories.