Documentation
¶
Overview ¶
Package transcript is the box's durable transcript: every settled entity revision, kept on the workspace volume (~/.plural/transcripts) so it survives suspends, snapshots and daemon restarts, and served to the gateway by Daemon.GetTimeline.
Layout, under one gocloud.dev/blob bucket (fileblob on the box, memblob in tests):
sessions/<session>/segments/<seq>-<nanos>-<rand>.ndjson.zst append-only batches of AcpEntity revisions sessions/<session>/snapshot/index.json position index of the current compacted snapshot sessions/<session>/snapshot/g<gen>/<chunk>.ndjson.zst latest revision of every entity, by position
Segments are written once and never modified. Records are idempotent on (type, id, revision) and every reader keeps the highest revision per key. The compactor folds segments into a new snapshot generation, then deletes the folded segments and the previous generation. Readers tolerate objects disappearing under them by retrying.
Index ¶
- Constants
- type Option
- type Page
- type Store
- func (s *Store) Append(ctx context.Context, entities []*devboxv1.AcpEntity) error
- func (s *Store) Close() error
- func (s *Store) Compact(ctx context.Context, session string) error
- func (s *Store) CompactAll(ctx context.Context, force bool) error
- func (s *Store) Reset(ctx context.Context) error
- func (s *Store) Timeline(ctx context.Context, session string, after uint64, limit int, ...) (*Page, error)
- func (s *Store) TimelineBefore(ctx context.Context, session string, before uint64, limit int, ...) (*Page, error)
Constants ¶
const ( // DefaultChunkSize is the number of entities per compacted snapshot chunk, i.e. the paging granularity. DefaultChunkSize = 500 // DefaultCompactThreshold is the number of segments that makes a session worth compacting. DefaultCompactThreshold = 16 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a box's transcript.
func (*Store) Append ¶
Append durably writes one batch of entity revisions, one segment per session. Entities without a session are rejected.
func (*Store) Compact ¶
Compact folds a session's segments into a new snapshot generation. It is a no-op without segments.
func (*Store) CompactAll ¶
CompactAll compacts every session with at least the configured number of segments, or every session with any segment when force is set.
func (*Store) Reset ¶
Reset deletes the whole transcript (a snapshot restored as a new instance starts with an empty history).
func (*Store) Timeline ¶
func (s *Store) Timeline(ctx context.Context, session string, after uint64, limit int, overlay []*devboxv1.AcpEntity) (*Page, error)
Timeline returns up to limit entities with position > after, merging the compacted snapshot, uncompacted segments and overlay (revisions the caller holds in memory; they win when their revision is higher).
func (*Store) TimelineBefore ¶
func (s *Store) TimelineBefore(ctx context.Context, session string, before uint64, limit int, overlay []*devboxv1.AcpEntity) (*Page, error)
TimelineBefore returns the newest limit entities with position < before (0: the newest of all), in position order. HasMore says older entities exist and NextPosition is the cursor for them.