Documentation
¶
Overview ¶
Package lock provides file-based mutual exclusion for single-instance enforcement.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureDirExists ¶ added in v0.174.0
EnsureDirExists creates the directory containing path with mode 0750 if it does not exist.
func FileLockPath ¶ added in v0.174.0
FileLockPath returns the lock file path for a given target file path.
Types ¶
type FileLock ¶ added in v0.174.0
type FileLock interface {
// Acquire attempts to acquire the lock, polling every 100ms until
// the lock is acquired, the timeout elapses, or the context is cancelled.
// Returns an error naming the path and the elapsed timeout on failure.
Acquire(ctx context.Context, timeout time.Duration) error
// Release unlocks and removes the lock file. Idempotent — calling on an
// already-released lock returns nil.
Release(ctx context.Context) error
}
FileLock provides exclusive file-based locking with a per-path lock file. Unlike Locker (which locks a project-wide .dark-factory.lock), FileLock is used to serialize mutations to individual files so that concurrent processes (e.g. a daemon and the doctor command) cannot corrupt mid-write.
func NewFileLock ¶ added in v0.174.0
NewFileLock creates a FileLock for the given target path. The lock file is <path>.lock in the same directory as path.