redis

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LockExpiry        time.Duration = 60 * time.Second
	LockRetryDelay    time.Duration = 100 * time.Millisecond
	LockExtendDelay   time.Duration = 333 * time.Millisecond
	LockDriftFactor   float64       = 0.01
	LockTimeoutFactor float64       = 0.05
)
View Source
var ErrExtendFailed = errors.New("redsync: failed to extend lock")
View Source
var ErrTaken = errors.New("lock already taken")

Functions

func AcquireRedisPool

func AcquireRedisPool(
	clients []*goredislib.Options,
) []redis.Pool

func NewPool

func NewPool(delegate rueidiscompat.Cmdable) redis.Pool

NewPool returns a rueidis-based pool implementation.

Types

type ErrNodeTaken

type ErrNodeTaken struct {
	Node int
}

ErrNodeTaken is the error resulting if the lock is already taken in one of the cluster's nodes

func (ErrNodeTaken) Error

func (err ErrNodeTaken) Error() string

type Lock

type Lock struct {
	*lock.LockOptions
	// contains filtered or unexported fields
}

func NewLock

func NewLock(
	pools []redis.Pool,
	quorum int,
	prefix, key string,
	lg *slog.Logger,
	opts *lock.LockOptions,
) *Lock

func (*Lock) Lock

func (l *Lock) Lock(ctx context.Context) (expired <-chan struct{}, err error)

func (*Lock) TryLock

func (l *Lock) TryLock(ctx context.Context) (acquired bool, expired <-chan struct{}, err error)

func (*Lock) Unlock

func (l *Lock) Unlock() error

type LockManager

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

func NewLockManager

func NewLockManager(
	ctx context.Context,
	prefix string,
	pools []redis.Pool,
	lg *slog.Logger,
) *LockManager

func (*LockManager) Health

func (lm *LockManager) Health(ctx context.Context) (conditions []string, err error)

func (*LockManager) NewLock

func (lm *LockManager) NewLock(key string, opt ...lock.LockOption) lock.Lock

type RedisError

type RedisError struct {
	Node int
	Err  error
}

A RedisError is an error communicating with one of the Redis nodes.

func (RedisError) Error

func (err RedisError) Error() string

Jump to

Keyboard shortcuts

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