Skip to content

Refactor IEventReader to use IAsyncEnumerable for streaming event reads  #523

@qodo-free-for-open-source-projects

Description

Description

  • The current IEventReader interface returns materialized Task<StreamEvent[]> arrays, which is inefficient for large streams as it requires loading all events into memory
  • The failIfNotFound parameter creates inconsistent behavior across implementations and complicates the interface contract
  • Streaming results with IAsyncEnumerable enables memory-efficient processing of large event streams while maintaining backward compatibility through extension methods

Deliverables

  • Interface redesign: Change ReadEvents and ReadEventsBackwards to return IAsyncEnumerable<StreamEvent> without failIfNotFound parameter
  • Backward compatibility: Implement extension methods in StoreFunctions that preserve old signatures with failIfNotFound behavior
  • Implementation updates: Refactor all event store implementations (KurrentDB, SQL, Redis, Elastic, InMemory, Tiered, Traced) to use async enumerable with yield return
  • Tracing support: Add TraceEnumerable method to BaseTracer for proper instrumentation of async enumerable operations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions