stream

package
v0.0.0-...-4afd048 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package stream composes durable event history with the live event bus into a single, ordered stream for external consumers (API, CLI, inspector). It is the only place that combines event.Store replay with event.Bus subscription.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Subscribe

func Subscribe(ctx context.Context, bus *event.Bus, store *event.Store, executionID core.ID, after core.ID) (<-chan Message, error)

Subscribe delivers every event for the execution: persisted history first (with an optional resume cursor), then live bus events. Events already delivered are skipped when they arrive again from the other source, so clients see each event exactly once. The returned channel is closed when ctx ends or the subscription is released.

History is not a one-time snapshot. The bus hands an event to the persister and to live subscribers independently, so an event published just before a consumer subscribes can still be missing from the store when the first history read happens. That event is then visible to neither the subscription nor the snapshot, and a consumer waiting for the terminal event waits forever. The stream therefore reconciles with the store while it is live rather than trusting the initial snapshot.

Types

type Message

type Message struct {
	EventID       core.ID
	Type          event.Type
	CorrelationID core.ID
	CapabilityID  core.ID
	OccurredAt    time.Time
	Payload       json.RawMessage
}

Message is the normalized stream unit. Payload is raw JSON regardless of whether the source was a typed live event or persisted history.

Jump to

Keyboard shortcuts

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