locker

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lock

type Lock interface {
	Release(ctx context.Context) error
	Refresh(ctx context.Context, duration time.Duration) error
	Key() string
}

type Locker

type Locker interface {
	Acquire(ctx context.Context, key string, ttl time.Duration, metadata string) (Lock, error)
}

type RedisLocker

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

RedisLocker : Implementation of Locker interface based on redis

func NewRedisLocker

func NewRedisLocker(rdb *redis.Client) *RedisLocker

NewRedisLocker : Returns a new RedisLocker based on supplied client

func (*RedisLocker) Acquire

func (rl *RedisLocker) Acquire(ctx context.Context, key string, ttl time.Duration, metadata string) (Lock, error)

Acquire : Attempts to acquire the redis lock for the key appending __lock: prefix

Jump to

Keyboard shortcuts

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