flock

package
v0.9.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package flock provides a small cross-process advisory file lock.

Multiple LabLinkServer processes can share the same operator config directory (one per AI client session). Without an OS-level lock, plain in-process mutexes are not enough to keep nodes.json or history.jsonl consistent across processes. This package wraps platform-specific locking primitives behind a single Lock/Unlock interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Locker

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

Locker is an exclusive, blocking advisory file lock. Lock blocks until the lock is acquired. Close releases the lock and the underlying file handle.

func Lock

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

Lock opens (creating if needed) the named file and acquires an exclusive advisory lock on it. Callers must Close the returned Locker to release it.

The lock file itself is a sidecar — it never holds data. Use a path like "<target>.lock" so that operations on <target> can be serialised across processes without holding a handle on <target> itself.

func (*Locker) Close

func (l *Locker) Close() error

Close releases the lock and closes the file handle.

Jump to

Keyboard shortcuts

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