package local¶
Package local stores state snapshots on the local filesystem.
The Backend interface and Snapshot types live in pkg/sdk/state so provider libraries can implement their own backends without depending on unobin core. The fixed set an operator selects from lives in pkg/backends.
Types¶
type Store¶
Store reads and writes snapshots under a per-stack directory. Layout is as follows:
<Root>/<Factory>/<Stack>/
current // File containing the SHA of the current snapshot.
snapshots/
<rev>.json.enc // rev is an RFC3339Nano timestamp
...
func NewStore¶
NewStore returns a Store for the given factory and stack under root, creating the directory tree if it doesn't exist. The Encrypter is required, but a pass-through (encrypters.Noop) can be passed for tests.
func (*Store) Current¶
Current returns the snapshot named by the current pointer. Returns sdkstate.ErrNoCurrent when no snapshot has been written yet.
func (*Store) CurrentRev¶
CurrentRev returns the rev the current pointer names, or sdkstate.ErrNoCurrent.
func (*Store) Delete¶
Delete removes the snapshot with the given rev. Removing a rev that does not exist is not an error.
func (*Store) ForceUnlock¶
ForceUnlock removes the lock marker without checking who holds it. Operators run this to recover after a leaked lock and must ensure no concurrent run is in progress.
func (*Store) Get¶
Get returns the snapshot with the given rev.
func (*Store) List¶
List returns the revs of every stored snapshot in chronological order.
func (*Store) Lock¶
Lock acquires the stack's exclusive lock by creating a marker file under the stack directory. Lock blocks until the marker can be created or ctx is canceled. The marker file holds the holder's pid so an operator can identify a stuck lock.
func (*Store) SetCurrent¶
SetCurrent atomically points "current" at the named rev. The snapshot must already exist.
func (*Store) Stack¶
Stack returns the stack name this store was constructed for. Required by the Backend interface.
func (*Store) Write¶
Write commits snap to disk and returns its rev. The caller advances the current pointer with SetCurrent. Each rev starts as an RFC3339Nano timestamp; if a snapshot already exists at that path (because two writes share the same nanosecond), a numeric suffix is appended until the path is fresh, so uniqueness does not depend on the clock advancing between writes.