redislocker

package
v0.0.0-...-2e4c9f4 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LockExchangeChannel = "tusd_lock_release_request_%s"
	LockReleaseChannel  = "tusd_lock_released_%s"
	LockExpiry          = 8 * time.Second
)

Functions

This section is empty.

Types

type BidirectionalLockExchange

type BidirectionalLockExchange interface {
	LockExchange
	ReleaseChannel(ctx context.Context, id string) <-chan *redis.Message
	Release(ctx context.Context, id string) error
}

type LockExchange

type LockExchange interface {
	Listen(ctx context.Context, id string, callback func())
	Request(ctx context.Context, id string) error
}

type LockerOption

type LockerOption func(l *RedisLocker)

func WithLogger

func WithLogger(logger *slog.Logger) LockerOption

func WithMutexCreator

func WithMutexCreator(uri string) (LockerOption, error)

type MutexLock

type MutexLock interface {
	TryLockContext(context.Context) error
	ExtendContext(context.Context) (bool, error)
	UnlockContext(context.Context) (bool, error)
	Until() time.Time
}

type RedSyncMutex

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

func (*RedSyncMutex) CreateMutex

func (rsm *RedSyncMutex) CreateMutex(id string) MutexLock

type RedisLockExchange

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

func (*RedisLockExchange) Listen

func (e *RedisLockExchange) Listen(ctx context.Context, id string, callback func())

func (*RedisLockExchange) Release

func (e *RedisLockExchange) Release(ctx context.Context, id string) error

func (*RedisLockExchange) ReleaseChannel

func (e *RedisLockExchange) ReleaseChannel(ctx context.Context, id string) <-chan *redis.Message

func (*RedisLockExchange) Request

func (e *RedisLockExchange) Request(ctx context.Context, id string) error

type RedisLocker

type RedisLocker struct {
	//rs          *redsync.Redsync
	CreateMutex func(id string) MutexLock
	// contains filtered or unexported fields
}

func New

func New(uri string, lockerOptions ...LockerOption) (*RedisLocker, error)

func (*RedisLocker) Health

func (*RedisLocker) NewLock

func (locker *RedisLocker) NewLock(id string) (handler.Lock, error)

func (*RedisLocker) UseIn

func (locker *RedisLocker) UseIn(composer *handler.StoreComposer)

Jump to

Keyboard shortcuts

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