Skip to main content

Module streaming

Module streaming 

Source
Expand description

Cursor-based event streaming — enables downstream consumers to subscribe to indexed events with resumable, at-least-once delivery.

Consumers maintain a cursor (position) and can resume from where they left off after crashes or restarts. Each consumer tracks its own independent cursor, so multiple consumers can process the same event stream at different rates.

§Architecture

Indexer  ──push()──>  EventStream  ──next_batch()──>  Consumer A
                          │                           Consumer B
                          │                           Consumer C
                          └── ring buffer (bounded)

§Reorg Handling

When a chain reorganization is detected, call invalidate_after(block_number) to remove all events at or above that block and bump the stream version. Consumers holding cursors with an older version must re-fetch from a known-good position.

Structs§

EventBatch
A batch of events returned to a consumer.
EventStream
In-memory event stream buffer that supports multiple consumers.
StreamConfig
Configuration for event streaming.
StreamCursor
An opaque cursor representing a position in the event stream.