distlock

package
v0.0.0-...-1cbeb1b Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPollingPeriod time.Duration
View Source
var DefaultTtl time.Duration

Functions

func PollStatusUntil

func PollStatusUntil(lockToPoll DistributedLocker, period time.Duration, eval StatusEvaluator) error

Types

type DistributedLocker

type DistributedLocker interface {
	GetLockStatus() LockStatusResult
	WaitUntilUnlock(deadline time.Time) (err error)
	TryLock() LockStatusResult
	TryUnlock() LockStatusResult
	TryForceLock() LockStatusResult
	KeepAlive() (result LockStatusResult)
}

func NewGoRedisLocker

func NewGoRedisLocker(keyPrefix string, lockId string, ttlSeconds time.Duration, redis GoRedisClient) DistributedLocker

type GoRedisClient

type GoRedisClient interface {
	Get(key string) *goredis.StringCmd
	EvalSha(sha1 string, keys []string, args ...interface{}) *goredis.Cmd
	ScriptExists(hashes ...string) *goredis.BoolSliceCmd
	ScriptLoad(script string) *goredis.StringCmd
	SetNX(key string, value interface{}, expiration time.Duration) *goredis.BoolCmd
	TxPipeline() goredis.Pipeliner
	PSubscribe(channels ...string) *goredis.PubSub
}

type LockStatusResult

type LockStatusResult struct {
	IsLocked bool
	IsOwner  bool
	Error    error
}

type StatusEvaluator

type StatusEvaluator func(status LockStatusResult) (shouldContinue bool, err error)

Jump to

Keyboard shortcuts

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