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 ¶
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 ( // ErrPublish is an error for when use locks cannot be published ErrPublish = errors.New("Could not publish use lock") // ErrRemove is an error for when use locks cannot be removed ErrRemove = errors.New("Could not remove use lock") // 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) 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.