Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lock ¶
type Lock interface {
lock.Lock
// Update the internal state of the lock, setting the values. Returns true on success and false if this lock was
// already expired with the old values. In the latter case, the new values are not applied and it cannot be guaranteed
// that IsExpired has not yet returned false.
// This method must be called at least once, after the lock expired in order for the lock to cleanup internal
// resources correctly.
Update(lockId string, leaseUntil time.Time, warnTime time.Time, unlocked bool) bool
// Try to lock the "lock for update"
TryLockForUpdate() bool
// Lock the "lock for update", blocking
LockForUpdate()
// Unlock the "lock for update"
UnlockForUpdate()
// The current lockId
LockId() string
// The current lease is valid until
LeaseUntil() time.Time
// The current state of the unlocked flag
Unlocked() bool
// SetFencingToken sets the fencing token
SetFencingToken(token *big.Int)
}
Internal interface for a Lock. A lock internally has a LockId, a current LeaseUntil and a state Unlocked (which can be try even before LeaseUntil, e.g. if Unlock was called and successful). Also it receives the warnTime at which it should issue a message on the WarnChan. Use Update to update the internal state Additionally a Lock provides a "lock for update" which can be used externally by functions which need exclusivity when preparing a call to Update.
type WarnChanManager ¶
type WarnChanManager interface {
// Register new warnTime for a lock. Returns a chan that will receive the lockId that reached the warnTime. Result is nil
// after Close. The returned chan will be closed when the lock is unregistered, or, at the latest, on Close. Must call
// Unregister for the lock later. Will always return the same channel instance for the same lock while it is not unregistered.
// Will return nil always if warnChan is disabled.
Register(lockId string, warnTime time.Time) <-chan string
// Unregister the lock from the manager. Channel will be closed and no more messages will be sent.
Unregister(lockId string)
// Close the manager & free up resources, unregistering all remaining registered locks.
Close()
}
WarnChanManager is a central instance per Locker which manages all WarnChans of all Locks.
func NewNoopWarnChanManager ¶
func NewNoopWarnChanManager() WarnChanManager
func NewWarnChanManager ¶
func NewWarnChanManager(logger logger.Logger, clk clock.Clock) WarnChanManager
Click to show internal directories.
Click to hide internal directories.