Documentation
¶
Overview ¶
Package cqrs exposes the task-queue fact journal as a go-cqrs-lite event.Journal / event.SeekableJournal, so the go-cqrs-lite ecosystem (projections, watermill.CatchUpSubscriber, SSE brokers, metaengine) can consume queue facts directly.
The adapter is read-only by contract: facts are written exclusively by the queue stores inside their state-mutating transactions. Event IDs are synthetic, sequence-derived ULIDs (see seqEventID): lexicographic ULID order matches ascending Seq, no schema migration is needed, and the zero EventID decodes to position 0 (the journal start).
Index ¶
Constants ¶
const ( StreamTypeTask = "Task" StreamTypeSession = "Session" )
Stream types assigned to fact events. Session facts carry the synthetic "session:<id>" task identity and get their own stream type so consumers can separate interactive-session observations from task history.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FactJournal ¶
type FactJournal struct {
// contains filtered or unexported fields
}
FactJournal adapts a FactSource to the go-cqrs-lite journal interfaces. The zero EventID is the journal start: it decodes to position 0.
func NewFactJournal ¶
func NewFactJournal(source FactSource) *FactJournal
NewFactJournal adapts source (typically a queue store) as a go-cqrs-lite seekable journal.
func (*FactJournal) ReadFrom ¶
func (j *FactJournal) ReadFrom(ctx context.Context, afterEventID id.EventID, limit int) ([]event.Event, error)
ReadFrom implements event.SeekableJournal. Position is the synthetic sequence-encoded event ID; facts are returned in Seq order, up to limit when limit > 0. A cursor outside this journal's ID space (random or foreign ULID) drains to nothing with a nil error — the go-cqrs-lite dangling-cursor contract: an unknown position must never replay the journal, because replay would duplicate facts into projections.
type FactSource ¶
type FactSource interface {
Facts(ctx context.Context, after int64, limit int) ([]journal.Fact, error)
}
FactSource is the read side of the fact journal the adapter consumes. It matches the semantics of the queue stores' Facts method: facts with Seq strictly greater than after, in ascending Seq order, bounded to the most recent limit when limit > 0.
type SliceSource ¶
type SliceSource struct {
// contains filtered or unexported fields
}
SliceSource is an in-memory FactSource over an already-loaded fact slice (CLI rendering, tests, ephemeral tooling).
func NewSliceSource ¶
func NewSliceSource(facts []journal.Fact) *SliceSource
NewSliceSource returns a FactSource serving facts in memory with store semantics: Seq strictly greater than after, ascending, bounded to the most recent limit when limit > 0.