Documentation ¶
Index ¶
Constants ¶
View Source
const ( // LockTimeout is the expiration of a redis lock // if any operation is longer than this, it should // refresh the lock LockTimeout = 20 * time.Second // WaitTimeout maximum time to wait before returning control to caller. WaitTimeout = 1 * time.Minute // WaitRetry time to wait between retries WaitRetry = 100 * time.Millisecond )
Variables ¶
View Source
var ( // ErrTooManyRetries is the error returned when despite several tries // we never managed to get a lock ErrTooManyRetries = errors.New("abort after too many failures without getting the lock") )
Functions ¶
This section is empty.
Types ¶
type ErrorLocker ¶
type ErrorLocker interface { Lock() error Unlock() }
An ErrorLocker is a locker which can fail (returns an error)
func LongOperation ¶
func LongOperation(db prefixer.Prefixer, name string) ErrorLocker
LongOperation returns a lock suitable for long operations. It will refresh the lock in redis to avoid its automatic expiration.
type ErrorRWLocker ¶
type ErrorRWLocker interface { ErrorLocker RLock() error RUnlock() }
ErrorRWLocker is the interface for a RWLock as inspired by RWMutex
Click to show internal directories.
Click to hide internal directories.