IStreamQueryHandler<TQuery, TResult> interface
Namespace: Vitreous.Abstractions
Assembly: Vitreous.dll
Handles a stream query that reads state and produces items of type
TResult lazily over time.
public interface IStreamQueryHandler<TQuery, TResult> where TQuery : IStreamQuery<TResult>Type Parameters
Section titled “Type Parameters”TQuery
The stream query type.
TResult
The type of each item yielded by the stream.
Remarks
Section titled “Remarks”The handler returns a Result<T> wrapping the IAsyncEnumerable<T>
so that setup failures (validation, authorization) can be signalled before any item is yielded.
Once the stream is open, items flow as plain TResult.
Because C# does not allow yield return in a method that also returns
ValueTask<…>, split the handler into two methods: Handle for setup/validation
and a private iterator method for item production.
For handlers with no validation, use the optional [StreamQueryHandler<TQuery, TResult>](/Vitreous/api/vitreous/abstractions/streamqueryhandler-2/)
base class instead — it removes this split entirely.
Methods
Section titled “Methods”Handle(TQuery, CancellationToken)
Section titled “ Handle(TQuery, CancellationToken)”Validates and opens the stream. On success, returns the lazy sequence of items. On failure, returns an Error before any item is produced.
ValueTask<Result<IAsyncEnumerable<TResult>>> Handle(TQuery query, CancellationToken ct = default)Parameters
Section titled “Parameters”query TQuery
Returns
Section titled “Returns”ValueTask<Result<IAsyncEnumerable<TResult>>>