Table of Contents

Interface IStreamRequest<TItem>

Namespace
SimpleMediator
Assembly
SimpleMediator.dll

Represents a streaming request that produces a sequence of items asynchronously.

public interface IStreamRequest<out TItem>

Type Parameters

TItem

Type of each item produced by the stream.

Examples

// Large query with implicit pagination
public sealed record StreamProductsQuery(int PageSize = 100) : IStreamRequest<Product>;

// Real-time event stream
public sealed record StreamOrderUpdatesQuery(Guid OrderId) : IStreamRequest<OrderUpdate>;

// Batch processing with backpressure
public sealed record ProcessLargeFileQuery(string FilePath) : IStreamRequest<ProcessedRecord>;

Remarks

Stream requests are ideal for scenarios where data is produced incrementally: large result sets, real-time data feeds, batch processing with backpressure, or Server-Sent Events (SSE) in web applications.

Unlike IRequest<TResponse>, stream requests return an async enumerable that yields items one at a time, allowing efficient memory usage and early cancellation.

Each yielded item is wrapped in Either<MediatorError, TItem> to support Railway Oriented Programming. Errors can be yielded mid-stream without terminating the entire sequence, allowing partial results and graceful degradation.