Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAcquireLockTimeout = errors.New("acquiring lock error: timeout") ErrAcquireLockRetryExceeded = errors.New("acquiring lock error: retry limit exceeded") ErrAcquireLockCancelled = errors.New("acquiring lock error: context cancelled") ErrAcquireLockConflict = errors.New("acquiring lock error: request has conflicting lock value") ErrLockNotFound = errors.New("lock not found") ErrAcquireUnlockTimeout = errors.New("acquiring unlock error: timeout") ErrAcquireUnlockCancelled = errors.New("acquiring unlock error: cancelled") ErrAcquireUnockRetryExceeded = errors.New("acquiring unlock error: retry limit exceeded") ErrLockNotAcquired = errors.New("unlock failed: lock not acquired") ErrLockActionRequested = errors.New("lock action already requested") )
View Source
var ( DefaultRetryDelay = 10 * time.Millisecond DefaultAcquireTimeout = 100 * time.Millisecond DefaultTimeout = 10 * time.Second )
Functions ¶
This section is empty.
Types ¶
type LockOption ¶
type LockOption func(o *LockOptions)
func WithAcquireContext ¶
func WithAcquireContext(ctx context.Context) LockOption
func WithAcquireTimeout ¶
func WithAcquireTimeout(timeout time.Duration) LockOption
func WithExpireDuration ¶
func WithExpireDuration(expireDuration time.Duration) LockOption
func WithKeepalive ¶
func WithKeepalive(keepalive bool) LockOption
func WithRetryDelay ¶
func WithRetryDelay(delay time.Duration) LockOption
type LockOptions ¶
type LockOptions struct { // Upper time limit for acquiring locks AcquireTimeout time.Duration // Retry delay between lock attempts RetryDelay time.Duration // Custom context for acquiring the lock AcquireContext context.Context // Keepalive will keep the lock alive until the process running the lock exits, // or the client connect context is done Keepalive bool // How long the remote lock stays valid for, if Keepalive is false LockValidity time.Duration }
func DefaultLockOptions ¶
func DefaultLockOptions(acquireCtx context.Context) *LockOptions
func (*LockOptions) Apply ¶
func (o *LockOptions) Apply(opts ...LockOption)
type LockPrimitive ¶
type LockPrimitive struct {
// contains filtered or unexported fields
}
Modified sync.Once primitive
func (*LockPrimitive) Do ¶
func (l *LockPrimitive) Do(f func() error) error
Click to show internal directories.
Click to hide internal directories.