Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCorrupt = errors.New("snapshot: corrupt")
ErrCorrupt marks a snapshot file that exists but cannot be decoded. Callers (and the journal itself) treat this as "fall back", not "fail".
Functions ¶
This section is empty.
Types ¶
type BranchJournal ¶
type BranchRecord ¶
type BranchRecord struct {
RunID string `json:"run_id"`
SourceNode string `json:"source_node"`
From string `json:"from"`
To string `json:"to"`
When string `json:"when,omitempty"`
Otherwise bool `json:"otherwise,omitempty"`
Status BranchStatus `json:"status"`
Reason string `json:"reason"`
DecisionSeq int `json:"decision_seq"`
CreatedAt time.Time `json:"created_at"`
}
type BranchStatus ¶
type BranchStatus string
const ( BranchSelected BranchStatus = "selected" BranchSkipped BranchStatus = "skipped" )
type FileSnapshotJournal ¶ added in v0.4.0
type FileSnapshotJournal struct {
// contains filtered or unexported fields
}
FileSnapshotJournal is a durable, filesystem-backed SnapshotJournal.
Layout:
<baseDir>/<runID>/step_00042.json immutable per-step snapshots <baseDir>/<runID>/latest.json most recent snapshot (pointer)
Every write is atomic + durable: temp file -> fsync -> rename -> fsync(dir). Readers take no lock: rename() is atomic, so Recover observes either the previous or the new file, never a torn one. This keeps the read path cheap and eliminates reader/writer contention.
The writer mutex serializes the shared latest.json rename target. Under contention this is the correct trade-off: the critical section is dominated by kernel I/O, not the lock itself.
func NewFileSnapshotJournal ¶ added in v0.4.0
func NewFileSnapshotJournal(baseDir string) (*FileSnapshotJournal, error)
NewFileSnapshotJournal creates or opens a journal rooted at baseDir.
type MemoryBranchJournal ¶
type MemoryBranchJournal struct {
// contains filtered or unexported fields
}
func NewMemoryBranchJournal ¶
func NewMemoryBranchJournal() *MemoryBranchJournal
func (*MemoryBranchJournal) Get ¶
func (j *MemoryBranchJournal) Get(_ context.Context, runID, sourceNode string) ([]BranchRecord, bool, error)
func (*MemoryBranchJournal) Put ¶
func (j *MemoryBranchJournal) Put(_ context.Context, runID, sourceNode string, records []BranchRecord) error
type SQLBranchJournal ¶
type SQLBranchJournal struct {
// contains filtered or unexported fields
}
func NewSQLBranchJournal ¶
func NewSQLBranchJournal(db *sql.DB) *SQLBranchJournal
func (*SQLBranchJournal) EnsureSchema ¶
func (j *SQLBranchJournal) EnsureSchema(ctx context.Context) error
func (*SQLBranchJournal) Get ¶
func (j *SQLBranchJournal) Get(ctx context.Context, runID, sourceNode string) ([]BranchRecord, bool, error)
func (*SQLBranchJournal) Put ¶
func (j *SQLBranchJournal) Put(ctx context.Context, runID, sourceNode string, records []BranchRecord) error
type Snapshot ¶ added in v0.4.0
type Snapshot struct {
RunID string `json:"run_id"`
StepIndex int `json:"step_index"`
StateData map[string]any `json:"state_data"`
SpentMicros int64 `json:"spent_micros"`
Timestamp time.Time `json:"timestamp"`
}
Snapshot captures the resumable state of a run at a given step.