Class RetryInterceptor
The retry interceptor is responsible for retrying failed requests when the failure condition can be retried.
public class RetryInterceptor : IInvoker
- Inheritance
-
RetryInterceptor
- Implements
- Inherited Members
- Extension Methods
Remarks
A failed request can be retried if:
- MaxAttempts is not reached.
- Payload can be read again.
- The failure condition can be retried.
In order to be able to read again the request's payload, the retry interceptor decorates the payload with ResettablePipeReaderDecorator. The decorator can be reset as long as the buffered data doesn't exceed MaxPayloadSize.
The request can be retried under the following failure conditions:
- The status code carried by the response is Unavailable.
- The status code carried by the response is NotFound and the protocol is ice.
- The request failed with an IceRpcException with one of the following error:
- The error code is InvocationCanceled.
- The error code is ConnectionAborted or TruncatedData and the request has the Idempotent field.
If the status code carried by the response is Unavailable or NotFound (with the ice protocol), the address of the server is removed from the set of server addresses to retry on. This ensures the request won't be retried on the unavailable server.
Constructors
RetryInterceptor(IInvoker, RetryOptions, ILogger)
Constructs a retry interceptor.
public RetryInterceptor(IInvoker next, RetryOptions options, ILogger logger)
Parameters
next
IInvokerThe next invoker in the invocation pipeline.
options
RetryOptionsThe options to configure the retry interceptor.
logger
ILoggerThe logger.
Methods
InvokeAsync(OutgoingRequest, CancellationToken)
Sends an outgoing request and returns the corresponding incoming response.
public Task<IncomingResponse> InvokeAsync(OutgoingRequest request, CancellationToken cancellationToken)
Parameters
request
OutgoingRequestThe outgoing request being sent.
cancellationToken
CancellationTokenA cancellation token that receives the cancellation requests.
Returns
- Task<IncomingResponse>
The corresponding IncomingResponse.
Remarks
When request
is a two-way request, the returned task will not complete successfully
until after the request's Payload is fully sent and the response is received from
the peer. When the request is a one-way request, the returned task completes successfully with an empty response
when the request's Payload is fully sent. For all requests (one-way and two-way),
the sending of the request's PayloadContinuation can continue in a background task
after the returned task has completed successfully.