filelock

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTimeout is the default timeout for acquiring a file lock.
	DefaultTimeout = 5 * time.Second

	// FileLockPollInterval is how often to retry acquiring the file lock.
	FileLockPollInterval = 50 * time.Millisecond
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Locker

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

Locker provides file-based locking with timeout.

func New

func New(lockPath string, timeout time.Duration) *Locker

New creates a Locker for the given lock file path.

func (*Locker) Acquire

func (l *Locker) Acquire() (unlock func() error, err error)

Acquire acquires the file lock and returns an unlock function. The caller must call the unlock function to release the lock.

func (*Locker) WithLock

func (l *Locker) WithLock(fn func() error) (retErr error)

WithLock executes fn while holding the lock.

Jump to

Keyboard shortcuts

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