dlocker

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Namespace string = "_Locker"
)

Variables

View Source
var (
	ErrStatusBusy = errors.New("status busy")
)

Functions

func MutexLock

func MutexLock(lockID string, ttl int32, backend Backend) error

func MutexTryLock

func MutexTryLock(lockID string, ttl int32, deadline int64, backend Backend) bool

func MutexUnlock

func MutexUnlock(lockID string, backend Backend) error

Types

type Backend

type Backend interface {
	Get(key []byte) (*store.Value, error)
	TrySetWithTTL(key, value []byte, ttl uint32) error
	Del(key []byte) error
	Watch(key []byte) (notify store.Watcher, err error)
}

func NewLockerBackend

func NewLockerBackend(
	s store.Store,
	apply func(context.Context, *serverpb.RaftLogPayload, time.Duration) error,
) (Backend, error)

type LockerBackend

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

func (LockerBackend) Del

func (w LockerBackend) Del(key []byte) error

func (LockerBackend) Get

func (w LockerBackend) Get(key []byte) (*store.Value, error)

func (LockerBackend) TrySetWithTTL

func (w LockerBackend) TrySetWithTTL(key, value []byte, ttl uint32) error

func (LockerBackend) Watch

func (w LockerBackend) Watch(key []byte) (store.Watcher, error)

Jump to

Keyboard shortcuts

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