staging_lockfile

package
v1.59.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: Apache-2.0 Imports: 5 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StagingLockFile

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

StagingLockFile represents a file lock used to coordinate access to staging areas. Typical usage is via CreateAndLock or TryLockPath, both of which return a StagingLockFile that must eventually be released with UnlockAndDelete. This ensures that access to the staging file is properly synchronized both within and across processes.

WARNING: This struct MUST NOT be created manually. Use the provided helper functions instead.

func CreateAndLock

func CreateAndLock(dir string, pattern string) (*StagingLockFile, string, error)

CreateAndLock creates a new temporary file in the specified directory with the given pattern, then creates and locks a StagingLockFile for it. The file is created using os.CreateTemp. Typically, the caller would use the returned lock file path to derive a path to the lock-controlled resource (e.g. by replacing the "pattern" part of the returned file name with a different prefix) Caller MUST call UnlockAndDelete() on the returned StagingLockFile to release the lock and delete the file.

Returns:

  • The locked StagingLockFile
  • The name of created lock file
  • Any error that occurred during the process

If the file cannot be locked, this function will retry up to maxRetries times before failing.

func TryLockPath

func TryLockPath(path string) (*StagingLockFile, error)

TryLockPath attempts to acquire a lock on an specific path. If the file does not exist, it will be created.

Warning: If acquiring a lock is successful, it returns a new StagingLockFile instance for the file. Caller MUST call UnlockAndDelete() on the returned StagingLockFile to release the lock and delete the file.

func (*StagingLockFile) UnlockAndDelete

func (l *StagingLockFile) UnlockAndDelete() error

UnlockAndDelete releases the lock, removes the associated file from the filesystem.

WARNING: After this operation, the StagingLockFile becomes invalid for further use.

Jump to

Keyboard shortcuts

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