Interface IDispatchMiddlewareInvoker
Invokes registered IDispatchMiddleware components for a dispatch operation.
public interface IDispatchMiddlewareInvoker
- Extension Methods
Methods
InvokeAsync<T>(IDispatchMessage, IMessageContext, Func<IDispatchMessage, IMessageContext, CancellationToken, ValueTask<T>>, CancellationToken)
Executes each middleware component and returns the resulting IMessageResult.
ValueTask<T> InvokeAsync<T>(IDispatchMessage message, IMessageContext context, Func<IDispatchMessage, IMessageContext, CancellationToken, ValueTask<T>> nextDelegate, CancellationToken cancellationToken) where T : IMessageResult
Parameters
messageIDispatchMessageMessage being dispatched.
contextIMessageContextContext associated with the message.
nextDelegateFunc<IDispatchMessage, IMessageContext, CancellationToken, ValueTask<T>>Delegate to invoke after middleware.
cancellationTokenCancellationTokenToken used to cancel the operation.
Returns
- ValueTask<T>
The result produced by the middleware chain.
Type Parameters
TExpected type of the result.
Remarks
This method returns ValueTask<TResult> to avoid Task allocation on synchronous completion paths. When the middleware chain completes synchronously (e.g., cache hit, no middleware), no Task is allocated.