Framework.Sequencer.StreamEmitter (Framework v0.5.0)
View SourceSequencer event emitter for consumer conformance.
Provides authoritative range-scan based event delivery strictly by sequence. NOTIFY is used only as a wake hint - consumers must remain correct without it.
Core Guarantees
- Events delivered in strict sequence order
- Range-scan query: WHERE sequence > cursor ORDER BY sequence ASC
- No time-based ordering assumptions
- Gaps in sequence are tolerated (due to rollbacks)
- NOTIFY storms don't affect correctness
Summary
Functions
Get consumer lag in milliseconds for monitoring.
Calculate emit lag in milliseconds.
Get current head sequence for monitoring and debugging.
Send NOTIFY hint to wake up consumers.
Stream events from cursor position with strict sequence ordering.
Functions
Get consumer lag in milliseconds for monitoring.
Returns time between consumer's cursor position and head sequence.
Calculate emit lag in milliseconds.
Returns time between head sequence creation and current time. Used for observability and SLO monitoring.
Get current head sequence for monitoring and debugging.
Returns the highest sequence number in the outbox, or 0 if empty.
Send NOTIFY hint to wake up consumers.
This is called after successful event append to hint consumers to poll immediately rather than waiting for next scheduled poll. Consumers must remain correct even if NOTIFY fails or is lost.
Now also broadcasts via PubSub for real-time transport integration.
Stream events from cursor position with strict sequence ordering.
Returns events where sequence > cursor in ascending sequence order. This is the authoritative delivery mechanism - NOTIFY is only a hint.
Parameters
- cursor: Last processed sequence (events with sequence > cursor are returned)
- limit: Maximum events to return in this batch
Usage
Ensure :framework, :repo is configured before calling stream_from/2 so the
emitter can query your application's outbox table in sequence order.