Documentation
¶
Overview ¶
Package filelock provides cross-process advisory file locks for mutable files that are updated with a read-modify-write transaction.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAcquire = errors.New("file lock acquisition failed")
ErrAcquire indicates that a lock could not be acquired before the context was cancelled or its deadline elapsed.
Functions ¶
This section is empty.
Types ¶
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock is a cross-process advisory lock. Its path is deliberately stable and is never removed: callers normally use a sibling .lock file, which remains valid even when the protected file is atomically replaced.
func New ¶
New creates a lock backed by path. The path is usually the protected path with a .lock suffix.
func (*Lock) WithExclusive ¶
WithExclusive runs fn while holding an exclusive lock, or returns ErrAcquire when ctx finishes first. Locks are released even when fn returns an error.