local

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 11 Imported by: 1 module, 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

Overview

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	Root    string
	Factory string
	// contains filtered or unexported fields
}

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

func NewStore(
	root, factory, stack string,
	enc sdkencrypt.Encrypter,
) (*Store, error)

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

func (s *Store) Current() (*sdkstate.Snapshot, error)

Current returns the snapshot named by the current pointer. Returns sdkstate.ErrNoCurrent when no snapshot has been written yet.

func (*Store) CurrentRev

func (s *Store) CurrentRev() (string, error)

CurrentRev returns the rev the current pointer names, or sdkstate.ErrNoCurrent.

func (*Store) Delete

func (s *Store) Delete(rev string) error

Delete removes the snapshot with the given rev. Removing a rev that does not exist is not an error.

func (*Store) ForceUnlock

func (s *Store) ForceUnlock() error

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

func (s *Store) Get(rev string) (*sdkstate.Snapshot, error)

Get returns the snapshot with the given rev.

func (*Store) List

func (s *Store) List() ([]string, error)

List returns the revs of every stored snapshot in chronological order.

func (*Store) Lock

func (s *Store) Lock(ctx context.Context) (sdkstate.Lock, error)

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

func (s *Store) SetCurrent(rev string) error

SetCurrent atomically points "current" at the named rev. The snapshot must already exist.

func (*Store) Stack

func (s *Store) Stack() string

Stack returns the stack name this store was constructed for. Required by the Backend interface.

func (*Store) Write

func (s *Store) Write(snap *sdkstate.Snapshot) (string, error)

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.

Jump to

Keyboard shortcuts

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