Documentation
¶
Overview ¶
Package sessionledger supplies a shared in-memory ledger for runtime and application tests. No production composition root uses this fixture.
Index ¶
- type Store
- func (f *Store) ActiveRun(_ context.Context, sessionID string) (ledger.Run, error)
- func (f *Store) Admit(_ context.Context, params ledger.AdmitParams) (ledger.Run, bool, error)
- func (f *Store) Claim(_ context.Context, params ledger.ClaimParams) (ledger.Run, bool, error)
- func (f *Store) Counts() (admits, claims int)
- func (f *Store) ErrorCode(runID string) string
- func (f *Store) Finalize(_ context.Context, params ledger.FinalizeParams) (ledger.Run, bool, error)
- func (f *Store) Get(_ context.Context, runID string) (ledger.Run, error)
- func (f *Store) GetByInvocation(_ context.Context, sessionID, invocationID string) (ledger.Run, error)
- func (f *Store) InsertClaimed(runID, sessionID string, token int64, generation string)
- func (f *Store) InsertOrphan(runID, sessionID, invocationID, fingerprint string)
- func (f *Store) LatestRun(_ context.Context, sessionID string) (ledger.Run, error)
- func (f *Store) NextFencingToken(context.Context) (int64, error)
- func (f *Store) OrphanedRuns(_ context.Context, query ledger.OrphanQuery) ([]ledger.Run, error)
- func (f *Store) PrepareFinish(_ context.Context, params ledger.PrepareFinishParams) (ledger.Run, bool, error)
- func (f *Store) RequestAbort(_ context.Context, runID string) (ledger.Run, bool, error)
- func (f *Store) Resume(_ context.Context, runID string, token int64) (ledger.Run, bool, error)
- func (f *Store) SetFinalizeErr(err error)
- func (f *Store) SetPrepareErr(err error)
- func (f *Store) SetWaitingDecision(_ context.Context, runID string, token int64) (ledger.Run, bool, error)
- func (f *Store) StaleGenerationRuns(_ context.Context, query ledger.StaleGenerationQuery) ([]ledger.Run, error)
- func (f *Store) State(runID string) ledger.State
- func (f *Store) TerminalWrites() []ledger.FinalizeParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
Mu sync.Mutex
Runs map[string]*ledger.Run
// bySession preserves insertion order so ActiveRun is deterministic.
Order []string
Token int64
AdmitErr error
ClaimErr error
TokenErr error
PrepareErr error
FinalizeErr error
ClaimHook func(runID string)
Admits int
Claims int
Finalized []ledger.FinalizeParams
}
Store is an in-memory ledger with the same guarantees the PostgreSQL adapter provides: one active run per session, fenced idempotent transitions, and a monotonic token sequence. It exists so admission ordering can be tested without a database; the adapter's own SQL is covered by its integration test.
func (*Store) GetByInvocation ¶
func (*Store) InsertClaimed ¶
insertClaimed records a run that some owner took and never finished, which is what the reaper finds after that owner disappears.
func (*Store) InsertOrphan ¶
insertOrphan records an admission that committed under a process that died before it could claim anything.
func (*Store) OrphanedRuns ¶
func (*Store) PrepareFinish ¶
func (*Store) RequestAbort ¶
func (*Store) SetFinalizeErr ¶
func (*Store) SetPrepareErr ¶
func (*Store) SetWaitingDecision ¶
func (*Store) StaleGenerationRuns ¶
func (f *Store) StaleGenerationRuns(_ context.Context, query ledger.StaleGenerationQuery) ([]ledger.Run, error)
StaleGenerationRuns mirrors the adapter's keyset sweep: active rows that were claimed by an incarnation other than the current one, ordered so a cursor can page through them.
func (*Store) TerminalWrites ¶
func (f *Store) TerminalWrites() []ledger.FinalizeParams