filelock

package
v0.9.8-dev.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package filelock is the exclusive right to do one thing per state directory, held across processes.

It is an advisory lock on a file and not a leader election: whoever holds it does the work and everyone else notices through whatever the work publishes. The kernel releases it if the holder dies, which is the property a pid file cannot offer, and it is the reason this is written against each platform's own primitive rather than stubbed out.

It was `internal/indexing`'s, used by one caller. It moved here when a second wanted it: `serve` installing the supervisor unit, where eight editors starting at once would otherwise run eight `systemctl daemon-reload`s to arrive at the one daemon systemd was going to start anyway.

`internal/storage/generation` still carries a third copy with a different contract -- it takes the lock or fails, where this one refuses without waiting -- and has not been migrated.

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 one process's exclusive claim on a path.

func Acquire

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

Acquire takes the lock without waiting. A false return is not an error: it means another process holds it, which is the answer a caller wants rather than a delay it did not ask for.

func (*Lock) Release

func (lock *Lock) Release() error

Jump to

Keyboard shortcuts

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