Documentation
¶
Index ¶
Constants ¶
const LockPath = "/run/nftban/nft_operations.lock"
LockPath is the canonical lock file for all nft operations. Both Go (syscall.Flock) and shell (flock(1)) use this same file.
Variables ¶
var ErrLockBusy = fmt.Errorf("nft lock busy")
ErrLockBusy is returned when a non-blocking lock attempt finds the lock held
var ErrLockTimeout = fmt.Errorf("nft lock timeout")
ErrLockTimeout is returned when lock acquisition times out
Functions ¶
This section is empty.
Types ¶
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock represents an acquired file lock
func AcquireExclusive ¶
AcquireExclusive acquires an exclusive lock for nft write operations. Blocks until the lock is acquired or timeout expires. Use for: nft add element, nft delete element, nft flush set, reconciliation.
func AcquireShared ¶
AcquireShared acquires a shared lock for nft read operations. Multiple shared locks can be held simultaneously. Use for: rare direct nft list set reads (not for cache file reads).
func TryAcquireExclusive ¶
TryAcquireExclusive tries to acquire an exclusive lock without blocking. Returns nil, ErrLockBusy if the lock is already held.