Documentation
¶
Overview ¶
Package locker provides functions for distributed locking.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnexpectedRedisResponse = errors.New("locker: unexpected redis response")
ErrUnexpectedRedisResponse is the error returned when Redis command returns response of unexpected type.
Functions ¶
This section is empty.
Types ¶
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock implements distributed locking.
type LockResult ¶ added in v0.3.0
LockResult contains new lock and result of applying the lock.
type Locker ¶
type Locker struct {
// contains filtered or unexported fields
}
Locker defines parameters for creating new lock.
type Option ¶ added in v0.0.11
type Option func(locker *Locker)
Option is function for setting locker options.
func WithRandReader ¶ added in v0.0.12
WithRandReader sets random generator to generate a lock token. By default equals crypto/rand.Reader.
func WithRandSize ¶ added in v0.0.12
WithRandSize sets bytes size to read from random generator to generate a lock token. Must be greater than 0. By default equals 16.
type RedisClient ¶ added in v0.2.0
type RedisClient interface { Eval(ctx context.Context, script string, keys []string, args ...interface{}) *redis.Cmd EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *redis.Cmd ScriptExists(ctx context.Context, hashes ...string) *redis.BoolSliceCmd ScriptLoad(ctx context.Context, script string) *redis.StringCmd }
RedisClient is redis scripter interface.
Click to show internal directories.
Click to hide internal directories.