easyredlock

package
v0.0.0-...-8d33a24 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2021 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultOwnedTimeout = 2 * time.Second

DefaultOwnedTimeout is the duration for which the lock is valid

Variables

View Source
var (
	ErrNoResultCB = cuserror.NewWithErrorMsg("noResultCB")
)

Functions

func TryLock

func TryLock(redisCli *redis.Client, key string, cb LockResultCB) (err error)

func TryLockWithTimeout

func TryLockWithTimeout(redisCli *redis.Client, key string, tryTimeout, ownedTimeout time.Duration, cb LockResultCB) (err error)

func TryReentrantLock

func TryReentrantLock(redisCli *redis.Client, key, token string, cb ReentrantLockResultCB) (err error)

func TryReentrantLockWithTimeout

func TryReentrantLockWithTimeout(redisCli *redis.Client, key, token string, tryTimeout, ownedTimeout time.Duration, cb ReentrantLockResultCB) (err error)

Types

type LockResultCB

type LockResultCB func(key string, owned bool) error

type Manager

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

func NewManager

func NewManager(ctx context.Context, redisCli *redis.Client, log logger.Wrapper) *Manager

func (*Manager) TryLock

func (man *Manager) TryLock(key string, cb LockResultCB) (err error)

func (*Manager) TryLockWithTimeout

func (man *Manager) TryLockWithTimeout(key string, tryTimeout, ownedTimeout time.Duration, cb LockResultCB) (err error)

func (*Manager) TryReentrantLock

func (man *Manager) TryReentrantLock(key, token string, cb ReentrantLockResultCB) (err error)

func (*Manager) TryReentrantLockWithTimeout

func (man *Manager) TryReentrantLockWithTimeout(key, token string, tryTimeout, ownedTimeout time.Duration, cb ReentrantLockResultCB) (err error)

type ReentrantLockResultCB

type ReentrantLockResultCB func(key, token string, reentrant, owned bool) error

Jump to

Keyboard shortcuts

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