Documentation
¶
Overview ¶
Package operationlock coordinates CLI operations across processes.
Index ¶
- Variables
- func Acquire(appData, target, operation string) (func(), error)
- func AcquireShared(appData, target, operation string) (func(), error)
- func AcquireSharedWithin(appData, target, operation string, timeout time.Duration) (func(), error)
- func AcquireWithin(appData, target, operation string, timeout time.Duration) (func(), error)
- type Holder
Constants ¶
This section is empty.
Variables ¶
var ErrBusy = errors.New("lock held")
ErrBusy reports that another process holds a conflicting lock.
Functions ¶
func Acquire ¶
Acquire locks a target, or all targets when target is empty. operation names the command for the holder description. Lock files remain in place so another process cannot lock a replacement inode during release.
func AcquireShared ¶
AcquireShared holds an image read lock while independent instances clone it.
func AcquireSharedWithin ¶
AcquireSharedWithin waits for an image read lock, honoring the CLI timeout.
func AcquireWithin ¶
AcquireWithin is Acquire, retrying with backoff while the lock is busy for up to timeout. A zero timeout tries exactly once. When it gives up, the error names the processes holding the conflicting locks where they are known.
Types ¶
type Holder ¶
type Holder struct {
PID int `json:"pid"`
Program string `json:"program"`
Operation string `json:"operation,omitempty"`
Target string `json:"target,omitempty"`
Since time.Time `json:"since"`
}
Holder describes the process holding an exclusive lock. It is written into the lock file so a refused process can say who is busy. Locks cover a byte range far beyond the content (see lockFile), so the content stays readable on Windows too.