dlocker

package
v0.12.6 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package dlocker is a distributed locker for distributed objects whose access requires synchronization. The objects may reside in same process or different processes.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLeaseTimeExceeded happens when lock is held for longer that lease time
	ErrLeaseTimeExceeded = fmt.Errorf("maximum lease time is %d seconds", 10)
	// ErrLockNotHeld happens when calling Release on a locker that is Released
	ErrLockNotHeld = errors.New("lock is released")
)

Functions

This section is empty.

Types

type Locker

type Locker interface {
	Acquire(context.Context) error
	Release(context.Context) error
	Released() <-chan struct{}
}

Locker is a distributed locker for clients to implement

func NewRedisLocker

func NewRedisLocker(ctx context.Context, client *redis.Client, lockID string) Locker

NewRedisLocker creates a distributed locker using redis pub sub and set data structure

Jump to

Keyboard shortcuts

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