Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LocalLocksmith ¶
type LocalLocksmith struct {
// contains filtered or unexported fields
}
LocalLocksmith implements process-scoped locking
func NewLocalLocksmith ¶
func NewLocalLocksmith() *LocalLocksmith
NewLocalLocksmith returns an initialised LocalLocksmith
type Locker ¶
type Locker interface { Lock(ctx context.Context) error // Unlock releases the lock. Implementations of this can fail to unlock for // various reasons, so arguably this function should return an error. In // practice though, there's nothing useful you can do with the error and // the lock will expire at some point anyway. Unlock() }
Locker is a lock on a resource that can be locked and unlocked
type Locksmith ¶
Locksmith can forge locks
var DefaultLocksmith Locksmith
DefaultLocksmith is a global instance of Locksmith
type RedisLocksmith ¶
type RedisLocksmith struct { // ServiceName is used to scope locks to the current service only ServiceName string // Client is a Redis client Client *redis.Client // Timeout is the length of time to wait when trying to // acquire a lock before giving up and returning an error Timeout time.Duration // Expiration is the TTL to set on locks Expiration time.Duration }
RedisLocksmith is a Locksmith backed by Redis. It is important that there is only a single Redis node. This algorithm will not work with a Redis cluster.
Click to show internal directories.
Click to hide internal directories.