Documentation ¶
Overview ¶
Package redsync provides a Redis-based distributed mutual exclusion lock implementation as described in the post http://redis.io/topics/distlock.
Values containing the types defined in this package should not be copied.
Index ¶
- Variables
- type DelayFunc
- type Mutex
- func (m *Mutex) Extend() (bool, error)
- func (m *Mutex) ExtendContext(ctx context.Context) (bool, error)
- func (m *Mutex) Lock() error
- func (m *Mutex) LockContext(ctx context.Context) error
- func (m *Mutex) Unlock() (bool, error)
- func (m *Mutex) UnlockContext(ctx context.Context) (bool, error)
- func (m *Mutex) Valid() (bool, error)
- func (m *Mutex) ValidContext(ctx context.Context) (bool, error)
- type Option
- type OptionFunc
- type Redsync
Constants ¶
This section is empty.
Variables ¶
var ErrFailed = errors.New("redsync: failed to acquire lock")
Functions ¶
This section is empty.
Types ¶
type Mutex ¶
type Mutex struct {
// contains filtered or unexported fields
}
A Mutex is a distributed mutual exclusion lock.
func (*Mutex) ExtendContext ¶
Extend resets the mutex's expiry and returns the status of expiry extension.
func (*Mutex) Lock ¶
Lock locks m. In case it returns an error on failure, you may retry to acquire the lock by calling this method again.
func (*Mutex) LockContext ¶
Lock locks m. In case it returns an error on failure, you may retry to acquire the lock by calling this method again.
func (*Mutex) UnlockContext ¶
Unlock unlocks m and returns the status of unlock.
type Option ¶
type Option interface {
Apply(*Mutex)
}
An Option configures a mutex.
func WithDriftFactor ¶
WithDriftFactor can be used to set the clock drift factor.
func WithExpiry ¶
WithExpiry can be used to set the expiry of a mutex to the given value.
func WithGenValueFunc ¶
WithGenValueFunc can be used to set the custom value generator.
func WithRetryDelay ¶
WithRetryDelay can be used to set the amount of time to wait between retries.
func WithRetryDelayFunc ¶
WithRetryDelayFunc can be used to override default delay behavior.