filelocks

package
v2.27.7 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 6 Imported by: ? 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

Index

Constants

View Source
const LockFileSuffix = ".flock"

LockFileSuffix to use for lock files

Variables

View Source
var (

	// ErrPathEmpty indicates that no path was specified
	ErrPathEmpty = errors.New("lock path is empty")
	// ErrAcquireLockFailed indicates that it was not possible to lock the resource.
	ErrAcquireLockFailed = errors.New("unable to acquire a lock on the file")
)

Functions

func AcquireReadLock

func AcquireReadLock(file string) (*flock.Flock, error)

AcquireReadLock tries to acquire a shared lock to read from the file and returns a lock object or an error accordingly. Call with the file to lock. This function creates .lock file next to it.

func AcquireWriteLock

func AcquireWriteLock(file string) (*flock.Flock, error)

AcquireWriteLock tries to acquire a shared lock to write from the file and returns a lock object or an error accordingly. Call with the file to lock. This function creates an extra .lock file next to it.

func FlockFile

func FlockFile(file string) string

FlockFile returns the flock filename for a given file name it returns an empty string if the input is empty

func ReleaseLock

func ReleaseLock(lock *flock.Flock) error

ReleaseLock releases a lock from a file that was previously created by AcquireReadLock or AcquireWriteLock.

func SetLockCycleDurationFactor added in v2.12.0

func SetLockCycleDurationFactor(v int)

SetLockCycleDurationFactor configures the factor applied to the timeout allowed during a lock cycle. Subsequent calls to SetLockCycleDurationFactor have no effect

func SetMaxLockCycles added in v2.11.0

func SetMaxLockCycles(v int)

SetMaxLockCycles configures the maximum amount of lock cycles. Subsequent calls to SetMaxLockCycles have no effect

Types

This section is empty.

Jump to

Keyboard shortcuts

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