filelock

package
v1.55.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package filelock provides a small advisory whole-file lock used to serialize read-modify-write cycles on shared JSON state under NS_HOME across processes. It is the single owner of the OS locking primitive so callers do not each carry their own platform split.

This is not the daemon singleton lock: that one is held for a process lifetime and is what prevents two daemons owning one root (see internal/daemon/lock.go). These locks are short-lived and released as soon as the state file has been rewritten.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lock

type Lock struct {
	// contains filtered or unexported fields
}

Lock is a held advisory lock on a lock file.

func Acquire

func Acquire(path string) (*Lock, error)

Acquire blocks until the lock at path is held. The lock file is created if it does not exist and is never removed, so an unlink can never drop a lock a concurrent holder still owns.

func (*Lock) Release

func (l *Lock) Release()

Release unlocks and closes the lock file. It is safe on a nil Lock so callers can defer it unconditionally.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL