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) Name() string
- func (m *Mutex) Unlock() (bool, error)
- func (m *Mutex) UnlockContext(ctx context.Context) (bool, error)
- func (m *Mutex) Until() time.Time
- func (m *Mutex) Valid() (bool, error)
- func (m *Mutex) ValidContext(ctx context.Context) (bool, error)
- func (m *Mutex) Value() string
- type Option
- func WithDriftFactor(factor float64) Option
- func WithExpiry(expiry time.Duration) Option
- func WithGenValueFunc(genValueFunc func() (string, error)) Option
- func WithRetryDelay(delay time.Duration) Option
- func WithRetryDelayFunc(delayFunc DelayFunc) Option
- func WithTries(tries int) Option
- func WithValue(v string) Option
- type OptionFunc
- type Redsync
Constants ¶
This section is empty.
Variables ¶
var ErrExtendFailed = errors.New("redsync: failed to extend lock")
var ErrFailed = errors.New("redsync: failed to acquire lock")
ErrFailed is the error resulting if Redsync fails to acquire the lock afer exhausting all retries.
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 ¶
ExtendContext 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 ¶
LockContext 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 ¶
UnlockContext unlocks m and returns the status of unlock.
func (*Mutex) Until ¶ added in v4.4.0
Until returns the time of validity of acquired lock. The value will be zero value until a lock is acquired.
func (*Mutex) ValidContext ¶
ValidContext returns true if the lock acquired through m is still valid.
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.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
goredis
command
|
|
|
goredis/v7
command
|
|
|
goredis/v8
command
|
|
|
redigo
command
|
|