redlock

package
v0.38.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExtendFailed = errors.New("redis: failed to extend lock")

ErrExtendFailed is the error resulting if Redsync fails to extend the lock.

Functions

This section is empty.

Types

type DelayFunc

type DelayFunc func(tries int) time.Duration

A DelayFunc is used to decide the amount of time to wait between retries.

type Lock

type Lock struct {
	// contains filtered or unexported fields
}

A Lock is a distributed mutual exclusion lock.

func (*Lock) Lock

func (m *Lock) Lock(ctx context.Context) (context.Context, error)

Lock locks m. In case it returns an error on failure, you may retry to acquire the lock by calling this method again.

func (*Lock) Unlock

func (m *Lock) Unlock(ctx context.Context) error

Unlock unlocks m and returns the status of unlock.

func (*Lock) WaitForLock added in v0.31.0

func (m *Lock) WaitForLock(ctx context.Context) (context.Context, error)

func (*Lock) WaitForUnlock

func (m *Lock) WaitForUnlock(ctx context.Context) error

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

func NewPool

func NewPool(addresses string) *Pool

func (*Pool) DoAsync

func (p *Pool) DoAsync(actFn func(*redis.Client) (bool, error)) (int, error)

func (*Pool) DoUntilQuorumAsync

func (p *Pool) DoUntilQuorumAsync(quorum int, actFn func(*redis.Client) (bool, error)) (int, error)

func (*Pool) NewLock

func (p *Pool) NewLock(name string, options ...RedisOption) *Lock

NewMutex returns a new distributed mutex with given name.

type RedisOption

type RedisOption func(*Lock)

OptionFunc is a function that configures a mutex.

func WithDriftFactor

func WithDriftFactor(factor float64) RedisOption

WithDriftFactor can be used to set the clock drift factor.

func WithExpiry

func WithExpiry(expiry time.Duration) RedisOption

WithExpiry can be used to set the expiry of a mutex to the given value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL