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 ¶
- type Store
- func (s *Store) CurrentRev() (string, error)
- func (s *Store) Delete(rev string) error
- func (s *Store) ForceUnlock() error
- func (s *Store) GetV2(rev string) (*sdkstate.SnapshotV2, error)
- func (s *Store) List() ([]string, error)
- func (s *Store) Lock(ctx context.Context) (sdkstate.Lock, error)
- func (s *Store) SetCurrent(rev string) error
- func (s *Store) Stack() string
- func (s *Store) WriteV2(snap *sdkstate.SnapshotV2) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 ¶
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) 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) GetV2 ¶
func (s *Store) GetV2(rev string) (*sdkstate.SnapshotV2, error)
GetV2 returns the strict version-2 snapshot with the given revision.
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.