Documentation
¶
Overview ¶
Package checkpoint persists a single worker's resumable state to SQLite.
Index ¶
- type Disposition
- type Intent
- type JournalEntry
- type KnownState
- type Reconciliation
- type Store
- func (s *Store) AppendJournal(taskID, outcome string, at time.Time) error
- func (s *Store) Close() error
- func (s *Store) Cursor(key string) (string, bool, error)
- func (s *Store) Journal(limit int) ([]JournalEntry, error)
- func (s *Store) LoadIntent() (Intent, bool, error)
- func (s *Store) LoadKnownState() (KnownState, bool, error)
- func (s *Store) SaveIntent(i Intent) error
- func (s *Store) SaveKnownState(k KnownState) error
- func (s *Store) SetCursor(key, value string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Disposition ¶
type Disposition int
Disposition is the reconciliation outcome.
const ( // Resume means saved intent can be safely continued. Resume Disposition = iota // Diverged means live state contradicts the checkpoint; re-plan instead. Diverged )
func (Disposition) String ¶
func (d Disposition) String() string
String renders a Disposition for logs.
type JournalEntry ¶
JournalEntry is one assigned-task outcome.
type KnownState ¶
type KnownState struct {
System string
POI string
Docked bool
Credits float64
CargoJSON string
Tick int
}
KnownState is the last game-state snapshot used for restart reconciliation.
type Reconciliation ¶
type Reconciliation struct {
Disposition Disposition
Reasons []string
}
Reconciliation is the result of comparing a checkpoint against live state.
func Reconcile ¶
func Reconcile(saved, live KnownState, creditDropFraction float64) Reconciliation
Reconcile compares saved checkpoint state to freshly-fetched live state. A zero-value saved state (fresh worker, no checkpoint) always returns Resume. creditDropFraction is the fraction of saved credits whose loss flags divergence.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a per-worker SQLite checkpoint.
func (*Store) AppendJournal ¶
AppendJournal records one task outcome.
func (*Store) Journal ¶
func (s *Store) Journal(limit int) ([]JournalEntry, error)
Journal returns up to limit entries, newest first.
func (*Store) LoadIntent ¶
LoadIntent returns the intent row and whether one exists.
func (*Store) LoadKnownState ¶
func (s *Store) LoadKnownState() (KnownState, bool, error)
LoadKnownState returns the known-state row and whether one exists.
func (*Store) SaveIntent ¶
SaveIntent upserts the single intent row.
func (*Store) SaveKnownState ¶
func (s *Store) SaveKnownState(k KnownState) error
SaveKnownState upserts the single known-state row.