filelock

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package filelock is the advisory file lock the extension cache and the SDK staging take.

pig additive (D20): the shared cell cache and its locks have no upstream equivalent. A lock is held through flock(2) (LockFileEx on Windows); some file systems refuse it, as an NFS mount without a lock manager (ENOLCK), a FUSE file system or an SMB share (ENOSYS, EOPNOTSUPP) do.

Index

Constants

This section is empty.

Variables

View Source
var New = func(path string) Lock { return flock.New(path) }

New returns the lock on the file at path. Tests replace it with a lock that fails the way a file system without file locks does.

Functions

func Explain

func Explain(dir string, err error) error

Explain returns err, or, when the file system that holds dir refuses file locks, an error that names dir and the remedy and wraps err. The extension cache cannot run without file locks: its builders, readers and collector exclude each other through them, and pig does not start an extension from a cache it cannot protect. Such a lock failure is permanent, so the remedy is a different file system.

func Unsupported

func Unsupported(err error) bool

Unsupported reports whether err says the file system refuses file locks: no lock manager (ENOLCK), no flock (ENOSYS), or locking not supported (EOPNOTSUPP, ENOTSUP). Other failures, a contended lock among them, are not.

Types

type Lock

type Lock interface {
	TryLock() (bool, error)
	TryRLock() (bool, error)
	TryLockContext(ctx context.Context, retryDelay time.Duration) (bool, error)
	TryRLockContext(ctx context.Context, retryDelay time.Duration) (bool, error)
	RLock() error
	Unlock() error
}

Lock is the part of gofrs/flock the callers use. A lock is shared (the RLock forms) or exclusive, and is released by process death.

Jump to

Keyboard shortcuts

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