proclock

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package proclock is a cross-process advisory file lock used to single-flight credential refreshes across cooperating processes.

The lock file holds no data — it exists only as a flock(2) / LockFileEx handle. The advisory lock is released automatically when the holding process exits, so a crashed holder never wedges the lock permanently (the property a hand-rolled O_EXCL lockfile lacks).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileLock

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

FileLock is an advisory lock keyed to a filesystem path. Construct one per (path) with New. A FileLock is safe to reuse across Acquire calls but a single FileLock value must not be Acquired re-entrantly.

func New

func New(path string) *FileLock

New returns a FileLock for path. The file and its parent directory are created lazily on Acquire.

func (*FileLock) Acquire

func (l *FileLock) Acquire(ctx context.Context) (func(), error)

Acquire blocks until the exclusive lock is held or ctx is done. It returns an idempotent release func; call it to release the lock and close the underlying handle. Acquire applies defaultAcquireTimeout as a ceiling: if ctx already carries an earlier deadline, that deadline wins.

Jump to

Keyboard shortcuts

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