Documentation
¶
Overview ¶
Package autolock implements a small wrapper over github.com/bsm/redis-lock to automatically refresh locks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrLostLock = errors.New("lost lock")
ErrLostLock is returned if the lock has been lost to another process.
Functions ¶
This section is empty.
Types ¶
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock is returned by Acquire and represents an active lock.
func Acquire ¶
Acquire will attempt to the lock represented by the specified key. It will retry the acquisition using the configured delay. The returned lock is automatically refreshed until it is released. If the lock attempt failed nil is returned.
type Options ¶
type Options struct { // The time after a lock will release itself. // // Default: 5s LockTimeout time.Duration // The amount of initial retries to acquire the lock. // // Default: 0 RetryCount int // The delay between individual attempts to acquire the lock. // // Default: 100ms RetryDelay time.Duration // The interval of the refresh cycle. Should be considerably smaller than // the LockTimeout to ensure the lock is refreshed. // // Default: LockTimeout / 2 (2.5s) RefreshInterval time.Duration }
Options is used to configure the lock acquisition, refresh and release.
Click to show internal directories.
Click to hide internal directories.