cache

package
v0.126.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const TombstoneDirName = ".evicted"

TombstoneDirName is the directory directly below the source root that holds the tombstones of evicted source stores until they are purged (see internal/source/store). It is reserved: no source store may live in it, and everything in it is garbage.

Variables

View Source
var ErrReservedSourcePath = errors.New("path is reserved for evicted source data")

ErrReservedSourcePath reports a source path in the tombstone namespace.

View Source
var ErrSourceRootNotSet = errors.New("source root is not set")

ErrSourceRootNotSet reports a source eviction without a registered source root.

Functions

func AcquireExclusiveGCPathLock added in v0.120.0

func AcquireExclusiveGCPathLock(path string) (func(), error)

AcquireExclusiveGCPathLock waits for exclusive access to a source store's GC gate.

func AcquireExclusivePathLock added in v0.120.0

func AcquireExclusivePathLock(path string) func()

AcquireExclusivePathLock takes an exclusive repository lock and excludes all other holders.

func AcquirePathLock

func AcquirePathLock(sourcePath string) func()

AcquirePathLock takes an exclusive lock for a mutable source path, including across shared data volumes.

func AcquireRequiredExclusivePathLock added in v0.120.0

func AcquireRequiredExclusivePathLock(path string) (func(), error)

AcquireRequiredExclusivePathLock takes an exclusive path lock and fails if cross-process exclusion cannot be established.

func AcquireSharedGCPathLock added in v0.120.0

func AcquireSharedGCPathLock(path string) (func(), error)

AcquireSharedGCPathLock marks a source store as actively preparing or deploying without sharing a lock namespace with source mutation locks. Unlike ordinary source locks, it fails rather than silently dropping cross-process protection.

Below the source root (see SetSourceRoot), it also excludes the eviction of every store the path is nested in, and it records the store's use for source eviction once acquired and once released (see LastSourceUse). Paths in the tombstone namespace are rejected with ErrReservedSourcePath.

func AcquireSharedPathLock added in v0.120.0

func AcquireSharedPathLock(path string) func()

AcquireSharedPathLock takes a shared repository lock and excludes exclusive holders.

func AcquireSharedSourceMaintenanceLock added in v0.124.0

func AcquireSharedSourceMaintenanceLock(path string) (func(), error)

AcquireSharedSourceMaintenanceLock takes the same shared gate as AcquireSharedGCPathLock without recording a use of the store, for maintenance such as manual mirror compaction that must neither race with nor delay source eviction.

func HasNestedSourceStores added in v0.124.0

func HasNestedSourceStores(dir string) (bool, error)

HasNestedSourceStores reports whether a source store nested in dir has ever taken its GC gate, which leaves dir's tree lock file behind.

func IsReservedSourceName added in v0.124.0

func IsReservedSourceName(name string) bool

IsReservedSourceName reports whether name, the path of a source store relative to the source root, is in the tombstone namespace.

func IsReservedSourcePath added in v0.124.0

func IsReservedSourcePath(path string) bool

IsReservedSourcePath reports whether path is in the tombstone namespace below the source root.

func IsSourceGateLockFile added in v0.124.0

func IsSourceGateLockFile(name string) bool

IsSourceGateLockFile reports whether name is the name of a GC gate or tree lock file, which only exist next to the base directory of a source store or a directory a source store is nested in.

func LastSourceUse added in v0.124.0

func LastSourceUse(path string) (time.Time, error)

LastSourceUse returns when the source store at path was last used by a holder of its GC gate (see AcquireSharedGCPathLock), or the zero time if it never was.

func NewPathLocker added in v0.120.0

func NewPathLocker(path string) sync.Locker

NewPathLocker adapts the process-and-filesystem path lock to sync.Locker. It lets a callee lock multiple scoped phases without losing cross-process exclusion.

func SetSourceRoot added in v0.124.0

func SetSourceRoot(root string) func()

SetSourceRoot registers root, the data directory holding all source stores. Below it, source gates also coordinate with the stores their store is nested in, and the tombstone namespace is reserved. It returns a function restoring the previous root.

func TryAcquireExclusiveGCPathLock added in v0.120.0

func TryAcquireExclusiveGCPathLock(path string) (func(), bool, error)

TryAcquireExclusiveGCPathLock prevents new deployments from crossing their in-flight-to-labeled transition while a source store is scanned. Failure to obtain cross-process exclusion skips the sweep.

func TryAcquireExclusivePathLock added in v0.120.0

func TryAcquireExclusivePathLock(path string) (func(), bool, error)

TryAcquireExclusivePathLock attempts to take an exclusive path lock without waiting. It returns false when another process or goroutine currently holds the path.

func TryAcquireSourceEvictionLock added in v0.124.0

func TryAcquireSourceEvictionLock(path string) (func(), bool, error)

TryAcquireSourceEvictionLock attempts to take everything needed to remove the source store at path, without waiting: its GC gate exclusively, so no deployment, scheduled run or artifact sweep uses it, its tree lock exclusively, so no store can be prepared below it, and the tree locks of the stores it is nested in shared, so none of them is evicted at the same time. It returns false if any of them is held.

path must be strictly below the source root (see SetSourceRoot) and outside the tombstone namespace.

Types

This section is empty.

Jump to

Keyboard shortcuts

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