Table of Contents

Interface IDispatchMiddlewareInvoker

Namespace
Excalibur.Dispatch
Assembly
Excalibur.Dispatch.Abstractions.dll

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

message IDispatchMessage

Message being dispatched.

context IMessageContext

Context associated with the message.

nextDelegate Func<IDispatchMessage, IMessageContext, CancellationToken, ValueTask<T>>

Delegate to invoke after middleware.

cancellationToken CancellationToken

Token used to cancel the operation.

Returns

ValueTask<T>

The result produced by the middleware chain.

Type Parameters

T

Expected 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.