Class DeadlineMiddleware
Represents a middleware that decodes deadline fields into deadline features. When the decoded deadline expires, this middleware cancels the dispatch and returns an OutgoingResponse with status code DeadlineExceeded.
public class DeadlineMiddleware : IDispatcher
- Inheritance
-
DeadlineMiddleware
- Implements
- Inherited Members
Remarks
If the peer-encoded deadline is too far in the future for this middleware to enforce (more than ~24.8 days from now), the request is rejected with NotSupported instead.
Constructors
DeadlineMiddleware(IDispatcher, TimeProvider?)
Constructs a deadline middleware.
public DeadlineMiddleware(IDispatcher next, TimeProvider? timeProvider = null)
Parameters
nextIDispatcherThe next dispatcher in the dispatch pipeline.
timeProviderTimeProviderThe optional time provider used to obtain the current time. If null, it uses System.
Methods
DispatchAsync(IncomingRequest, CancellationToken)
Dispatches an incoming request and returns the corresponding outgoing response.
public ValueTask<OutgoingResponse> DispatchAsync(IncomingRequest request, CancellationToken cancellationToken = default)
Parameters
requestIncomingRequestThe incoming request being dispatched.
cancellationTokenCancellationTokenA cancellation token that receives the cancellation requests.
Returns
- ValueTask<OutgoingResponse>
The outgoing response.