Documentation
¶
Overview ¶
Package lock implements coordinated etcd locking across multiple locks to provide a safe experience between different parts of the volplugin system.
Currently this package coordinates create, remove, mount and snapshot locks. Snapshot locks in particular are special; they are a secondary lock that exists for remove operations only.
goroutine-safe functions to manage TTL-safe reporting also exist here.
Index ¶
- Constants
- Variables
- type Driver
- func (d *Driver) AcquireWithTTLRefresh(uc config.UseLocker, ttl, timeout time.Duration) (chan struct{}, error)
- func (d *Driver) ClearLock(uc config.UseLocker, timeout time.Duration) error
- func (d *Driver) ExecuteWithMultiUseLock(ucs []config.UseLocker, timeout time.Duration, ...) error
- func (d *Driver) ExecuteWithUseLock(uc config.UseLocker, runFunc func(d *Driver, uc config.UseLocker) error) error
Constants ¶
const ( // ReasonCreate is the "create" reason for the lock ReasonCreate = "Create" // ReasonMount is the "mount" reason for the lock ReasonMount = "Mount" // ReasonRemove is the "remove" reason for the lock ReasonRemove = "Remove" // ReasonSnapshot is the "snapshot" reason for the lock ReasonSnapshot = "Snapshot" // ReasonSnapshotPrune is the prune operation for snapshots ReasonSnapshotPrune = "SnapshotPrune" // ReasonCopy indicates a copy from snapshot operation. ReasonCopy = "Copy" // ReasonMaintenance indicates that an operator is acquiring the lock. ReasonMaintenance = "Maintenance" )
Variables ¶
var ( // Unlocked is a string indicating unlocked operation, this is typically used // as a hostname for our locking system. Unlocked = "-unlocked-" )
Functions ¶
This section is empty.
Types ¶
type Driver ¶
Driver is the top-level struct for lock objects
func (*Driver) AcquireWithTTLRefresh ¶ added in v0.2.0
func (d *Driver) AcquireWithTTLRefresh(uc config.UseLocker, ttl, timeout time.Duration) (chan struct{}, error)
AcquireWithTTLRefresh accepts a UseLocker, and attempts to acquire the lock. When it successfully does, it then spawns a goroutine to refresh the lock after a timeout, returning a stop channel. Timeout is jittered to mitigate thundering herd problems.
func (*Driver) ExecuteWithMultiUseLock ¶
func (d *Driver) ExecuteWithMultiUseLock(ucs []config.UseLocker, timeout time.Duration, runFunc func(d *Driver, ucs []config.UseLocker) error) error
ExecuteWithMultiUseLock takes several UseLockers and tries to lock them all at the same time. If it fails, it returns an error. If timeout is zero, it will not attempt to retry acquiring the lock. Otherwise, it will attempt to wait for the provided timeout and only return an error if it fails to acquire them in time.