Documentation
¶
Overview ¶
Package state persists the apply resume cursor.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
DefaultPath returns the default state file path when no profile is known. Prefer ProfileStatePath for normal CLI use; DefaultPath is a fallback for direct API callers that do not have a profile root. It returns an error when neither XDG_STATE_HOME nor a user home directory is available so the empty string never flows into MkdirAll.
func ProfileStatePath ¶ added in v0.2.0
ProfileStatePath returns the default state file path for a profile root. The path is located under the XDG state directory so the profile directory is not polluted with runtime state.
Types ¶
type FileStore ¶
type FileStore struct {
Path string
// contains filtered or unexported fields
}
FileStore saves state to a JSON file.
Concurrency: mutual exclusion between processes is provided by an flock(LOCK_EX) on the sidecar file <Path>.lock (see Lock), never on the state file itself. Save replaces the state file via tmp+rename, so a lock taken on the state file's inode would stay behind on the unlinked inode while later openers lock the new inode — the sidecar path is stable across renames. Load and Save do NOT lock internally; callers that need a load→modify→save critical section must hold Lock across it (cmd/apply does). Lock-free readers are still safe: rename is atomic, so Load never observes a torn write.
func NewFileStore ¶
NewFileStore returns a FileStore using the given path. An empty path falls back to DefaultPath; if no default can be determined the store's Path stays empty and Load/Save/Lock return an explicit error.
func (*FileStore) Lock ¶ added in v0.2.0
Lock acquires the exclusive sidecar lock, blocking until it is available. Hold it across the entire load→pipeline→save window; it is idempotent on a FileStore that already holds it.
func (*FileStore) LockPath ¶ added in v0.2.0
LockPath returns the sidecar lock file path. The sidecar is never renamed, so a lock held on it survives Save's atomic tmp+rename of the state file.
func (*FileStore) Remove ¶ added in v0.14.0
Remove deletes the state file; a missing file is not an error.