Interface IPipelineBehavior<TRequest>
- Namespace
- Stratara.Abstractions.Mediator
- Assembly
- Stratara.Abstractions.dll
Pipeline behavior invoked around each IMediator dispatch of an IRequest
(commands without a result). Behaviors form a chain: each calls next to
invoke the next behavior or the handler at the chain's end.
public interface IPipelineBehavior<in TRequest> where TRequest : IRequest
Type Parameters
TRequestThe concrete request type the behavior observes.
- Extension Methods
Remarks
Behaviors run in DI registration order — the first registered behavior is the outermost
wrapper, the handler is invoked innermost. A behavior may short-circuit the pipeline by
returning without awaiting next. Register with
services.AddPipelineBehavior(typeof(MyBehavior<>)).
Methods
HandleAsync(TRequest, Func<Task>, CancellationToken)
Run the behavior around the rest of the pipeline.
Task HandleAsync(TRequest request, Func<Task> next, CancellationToken cancellationToken)
Parameters
requestTRequestThe dispatched request instance.
nextFunc<Task>Delegate invoking the next behavior or the final handler.
cancellationTokenCancellationTokenPropagated from the IMediator call site.