Documentation
¶
Overview ¶
Package flock provides a small cross-process advisory-lock primitive built on POSIX flock (Unix) / LockFileEx (Windows). It exists so that checkpoint and strategy can both serialize on shared resources without one taking the other as an import dependency.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Acquire ¶
Acquire takes an exclusive advisory lock on path, creating the file if needed. The returned release closes the file, which drops the flock. Callers must invoke release exactly once. The lock file persists between runs — flock state is held by the file descriptor, not by the inode on disk — so the lockfile contents are immaterial.
Acquire blocks indefinitely until the lock is available. Use AcquireContext with a deadline to bound the wait.
func AcquireContext ¶ added in v0.10.0
AcquireContext behaves like Acquire but honors ctx. When ctx carries a deadline it polls a non-blocking lock until the lock is acquired or the deadline/cancellation fires, returning a wrapped ctx.Err() on timeout. When ctx has no deadline it takes the same blocking kernel path as Acquire, so existing callers keep their exact behavior. This lets latency-critical hooks (turn-start) bound their wait and degrade gracefully instead of stalling behind a long-running lock holder (e.g. checkpoint condensation).
Types ¶
This section is empty.