state

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package state persists the snapshot that makes a fire reversible.

The ordering rule is absolute: the snapshot is written, and read back, before a single API call changes anything. If the write fails the fire is abandoned. An account that is still expensive is a problem; an account that is stopped with no record of how to start it is an outage of unknown length.

S3 is the intended home — it is in the never-touch set, so the kill switch cannot destroy its own restore — with a local copy alongside for the case where the reason you are firing is that something is wrong with the account.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("no snapshot with that plan id")

Functions

func From

func From(p model.Plan) model.Snapshot

From converts a plan into the record that will make it reversible.

func ParseURI

func ParseURI(uri string) (bucket, prefix string, ok bool)

ParseURI accepts s3://bucket/prefix.

func PutVerified

func PutVerified(ctx context.Context, s Store, snap model.Snapshot) error

PutVerified writes and reads back, comparing what returned against what was sent. A store that accepts a write and loses it is the one failure this tool cannot survive, and it is cheap to rule out.

Types

type Local

type Local struct{ Dir string }

func (Local) Describe

func (l Local) Describe() string

func (Local) Get

func (l Local) Get(ctx context.Context, planID string) (model.Snapshot, error)

func (Local) List

func (l Local) List(ctx context.Context) ([]model.Snapshot, error)

func (Local) Put

func (l Local) Put(ctx context.Context, s model.Snapshot) error

type Multi

type Multi struct{ Stores []Store }

Multi writes to every store and requires all of them to succeed, so the local copy and the durable copy cannot disagree about what was stopped.

func (Multi) Describe

func (m Multi) Describe() string

func (Multi) Get

func (m Multi) Get(ctx context.Context, planID string) (model.Snapshot, error)

Get reads from the first store that has it. Order matters: the durable store should come first, since the local one may be on a machine that was rebuilt.

func (Multi) List

func (m Multi) List(ctx context.Context) ([]model.Snapshot, error)

func (Multi) Put

func (m Multi) Put(ctx context.Context, s model.Snapshot) error

type S3

type S3 struct {
	Client *s3.Client
	Bucket string
	Prefix string
}

S3 is the durable home for snapshots.

S3 is in the never-touch set, which is not a coincidence: the kill switch must not be able to destroy its own restore record. Versioning on the bucket is worth turning on for the same reason.

func (S3) Describe

func (s S3) Describe() string

func (S3) Get

func (s S3) Get(ctx context.Context, planID string) (model.Snapshot, error)

func (S3) List

func (s S3) List(ctx context.Context) ([]model.Snapshot, error)

func (S3) Put

func (s S3) Put(ctx context.Context, snap model.Snapshot) error

type Store

type Store interface {
	Put(ctx context.Context, s model.Snapshot) error
	Get(ctx context.Context, planID string) (model.Snapshot, error)
	List(ctx context.Context) ([]model.Snapshot, error)
	Describe() string
}

func Build added in v1.10.0

func Build(s3c *s3.Client, uri, localDir string) (Store, error)

Build assembles the store a run should use: the durable one first, so a rebuilt laptop still finds the record, with the local directory behind it.

localDir may be empty, which is the Lambda's case — there is no durable filesystem there, and a local copy that dies with the execution environment would be a restore record that does not exist.

Jump to

Keyboard shortcuts

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