Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrContended error = errors.New("Could not obtain lock due to contention") ErrGenUuid error = errors.New("Error locking due to UUID generation failure") ErrHoldFor error = errors.New("Error locking - holdFor duration must be 2 seconds or greater") )
var (
ErrRegionHoldFor error = errors.New(fmt.Sprintf("Error locking - holdFor duration must be %v or greater", minRegionHoldFor))
)
var (
ErrReserved = errors.New("[Reservation] Item already reserved")
)
Functions ¶
func AnonymousRelease ¶
AnonymousRelease will release the reservation of the item with the given id and path
func CleanupRegionLeaders ¶
func CleanupRegionLeaders()
CleanupRegionLeaders is a cleanup callback function which is run when the service is interrupted and rescinds any outstanding region leaders.
func SetRegionLockNamespace ¶
func SetRegionLockNamespace(ns string)
SetRegionLockNamespace should be set to the service name on startup, and never again!
Types ¶
type DefaultReservation ¶
func (*DefaultReservation) Release ¶
func (dr *DefaultReservation) Release() error
Release will release the reservation in the DefaultReservation
type Leader ¶
type Leader interface { // Rescinded returns a channel that will be closed if/when leadership is rescinded Rescinded() chan struct{} // Rescind allows clients to manually rescind leadership Rescind() }
Leader is an interface used by return values on things that can elect a leader
func NewGlobalLeader ¶
NewGlobalLocker returns a global leader which is basically just a region leader pinned to one region based on config.
func RegionLeader ¶
RegionLeader block indefinitely until this invocation has been elected the "leader" within the local operating region. It will then return a channel that will eventually be closed when leadership is rescinded.
type Lock ¶
type Lock interface {
// Unlock allows clients to release the lock
Unlock()
}
Lock is an interface used by return values on things that can achieve a lock
func GlobalLock ¶
GlobalLock attempts to achieve a lock using default timing values of 1 second and 5 seconds
func GlobalTimedLock ¶
GlobalTimedLock attempts to achieve a global lock on `id`, waiting for `waitFor` time in case of contention (before giving up) and reserving the lock for a maximum `holdFor` in the event of failure NOTE: locks can and will be held for longer than `holdFor`, but in the case of failure (eg: binary crashes) then this is the maximum amount of time other programs will hang around contending for the now defunkt lock
func RegionLock ¶
RegionLock attempts to achieve a lock using default timing values
func RegionTimedLock ¶
RegionTimedLock attempts to achieve a regional lock on `id`, waiting for `waitFor` time in case of contention (before giving up) and reserving the lock for a maximum `holdFor` in the event of failing to Unlock()
type Reservation ¶
Reservation will reserve an item given an id. The reservation must expire and may be released at any time by any actor
func NewReservation ¶
func NewReservation(path, id string, acl []gozk.ACL) Reservation
NewReservation creates a default reservation