Documentation ¶
Overview ¶
Package state implements atomic file-based state management with support for advisory locking.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoState = errors.New("no state exists")
ErrNoState is returned when attempting to read a nonexistent state.
Functions ¶
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File implements file-based state management with support for advisory locking. It is also safe to use concurrently within a process.
func Open ¶
New creates and returns a new State at the given prefix. The following files are stored:
- {prefix}.json: the current state
- {prefix}.lock: the POSIX lock file
- {prefix}.bak: the previous state
func (*File) Lock ¶
Lock locks the state, both inside of the process and outside. Lock relies on POSIX flock, which may not be available on all filesystems, notably NFS and SMB.
Click to show internal directories.
Click to hide internal directories.