catalogreader

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package catalogreader is the concrete read-plane adapter behind serve.Reader. It implements serve's list/status/journal reads over the session store's catalog projection and event replayer, translating persisted SessionMeta / journal events into serve's transport DTOs.

It lives in its OWN package (not pkg/serve) on purpose: serve obeys strict Dependency Inversion and may not import any store package, so the adapter that DOES import pkg/sessionstore sits behind serve's Reader interface here. serve depends on the interface; the composition root wires this adapter in. Because this is a separate directory, serve's dependency-guard test (which scans only the serve directory) stays green.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateEventError

type PrivateEventError struct{ Visibility event.EventVisibility }

PrivateEventError reports an internal event encountered at a public serve reconstruction boundary. It contains no event payload.

func (*PrivateEventError) Error

func (e *PrivateEventError) Error() string

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader adapts a sessionstore Catalog + Store to serve.Reader. The Catalog backs the replay-free list and status reads (ListSessions / ReadMeta); the Store backs the journal read (OpenEventReplayer). It holds no per-request state — one Reader serves every read — so it is safe for concurrent use to the extent its backends are.

func New

func New(catalog *sessionstore.Catalog, store *sessionstore.Store) *Reader

New builds a Reader over the supplied catalog and store, wired at the composition root. Both are required; a nil argument is a programming error the composition root does not make and is not defended against here.

func (*Reader) ListSessions

func (r *Reader) ListSessions(ctx context.Context, page serve.Page) (serve.SessionList, error)

ListSessions reads EVERY catalog entry, stable-sorts it by last-active descending then session id ascending (the picker's most-recent-first order, SPEC §6), and returns the requested [Skip, Skip+Limit) window as summaries. Done reports the end of the list was reached (the window returned fewer than Limit entries); NextSkip is the resume offset when more may remain. A backend read failure is wrapped in a serve.StoreReadError (mapped to 500 by the handler). It trusts the Page — the HTTP boundary already validated Skip/Limit — but is bounds-safe against an out-of-range Skip.

func (*Reader) ReadJournal

func (r *Reader) ReadJournal(ctx context.Context, id uuid.UUID, page serve.JournalPage) (serve.EventJournalPage, error)

ReadJournal reads a page of a session's Enduring events from the store's event replayer, positioned at page.From (inclusive; 0 = beginning). It collects up to page.Limit events, then reports Done when the replayer drained BEFORE the limit was hit and NextJournalSeq (the last delivered sequence + 1) as the resume cursor when more may remain. GatePrepared never appears — the replayer filters it. A replayer open or read failure is wrapped in a serve.StoreReadError (500).

func (*Reader) ReadStatus

func (r *Reader) ReadStatus(ctx context.Context, id uuid.UUID) (serve.SessionStatus, error)

ReadStatus reads one session's projected status by a SINGLE catalog load — NEVER a replay. An absent entry yields a serve.SessionNotFoundError (mapped to 404); a backend read failure yields a serve.StoreReadError (500). The LastTurn/LastStep summaries are reconstructed losslessly from the meta's codec-safe eventSummary raw bytes via event.UnmarshalEvent, so the DTO carries the concrete event, not a lossy projection.

Jump to

Keyboard shortcuts

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