generated from dailydevops/template-dotnet
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
type:featureIndicates a new feature or enhancement to be added.Indicates a new feature or enhancement to be added.
Description
User Story
As a developer building query-heavy features over large data sets, I want streaming query support via IAsyncEnumerable<TResponse>, so that I can return results incrementally without buffering the entire result set in memory.
Background
The current IQuery<TResponse> pattern returns a single response object. Scenarios like paginated exports, report generation, or real-time feeds require returning potentially thousands of items. Using IAsyncEnumerable allows callers to process items as they arrive, reducing memory pressure.
Requirements
- Define
IStreamQuery<TResponse>inNetEvolve.Pulse.Extensibility:public interface IStreamQuery<TResponse> : IRequest<IAsyncEnumerable<TResponse>> { }
- Define
IStreamQueryHandler<TQuery, TResponse>inNetEvolve.Pulse.Extensibility:public interface IStreamQueryHandler<TQuery, TResponse> where TQuery : IStreamQuery<TResponse> { IAsyncEnumerable<TResponse> HandleAsync(TQuery query, CancellationToken ct); }
- Extend
IMediatorwith:IAsyncEnumerable<TResponse> StreamAsync<TQuery, TResponse>(TQuery query, CancellationToken ct = default) where TQuery : IStreamQuery<TResponse>;
- Implement
StreamAsyncinPulseMediatorfollowing the same single-handler enforcement asQueryAsync. IStreamQueryHandlersupports one handler per query type (same asIQueryHandler).- Interceptors (
IQueryInterceptor) do not apply to streaming queries in the initial implementation; streaming queries are executed directly. - Handler registration follows the existing
HandlerRegistrationExtensionspatterns.
Acceptance Criteria
-
IStreamQuery<TResponse>andIStreamQueryHandler<TQuery, TResponse>are defined inNetEvolve.Pulse.Extensibility. -
IMediator.StreamAsyncis implemented inPulseMediator. - Registering more than one handler for the same
IStreamQueryHandler<TQuery, TResponse>throwsInvalidOperationExceptionat dispatch time. - Dispatching a streaming query with no registered handler throws
InvalidOperationExceptionwith a descriptive message. - Cancellation via
CancellationTokenstops iteration without exception leaking to the caller. - Unit tests cover: normal streaming, cancellation, missing handler, and duplicate handler scenarios.
- Integration tests verify that a handler returning
yield returnitems is consumed correctly end-to-end. - XML documentation is provided for all new public members.
Out of Scope
- Interceptor pipeline support for streaming queries (planned for a follow-up).
- Streaming commands or streaming events.
- Server-Sent Events or SignalR integration.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type:featureIndicates a new feature or enhancement to be added.Indicates a new feature or enhancement to be added.