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:
<ul><li><xref href="IceRpc.Retry.RetryOptions.MaxAttempts" data-throw-if-not-resolved="false"></xref> is not reached.</li><li><xref href="IceRpc.OutgoingFrame.Payload" data-throw-if-not-resolved="false"></xref> can be read again.</li><li>The failure condition can be retried.</li></ul>
<p>In order to be able to read again the request's payload, the retry interceptor decorates the payload
with <xref href="IceRpc.ResettablePipeReaderDecorator" data-throw-if-not-resolved="false"></xref>. The decorator can be reset as long as the buffered data doesn't
exceed <xref href="IceRpc.Retry.RetryOptions.MaxPayloadSize" data-throw-if-not-resolved="false"></xref>.</p>
<p>The request can be retried under the following failure conditions:</p>
<ul><li>The status code carried by the response is <xref href="IceRpc.StatusCode.Unavailable" data-throw-if-not-resolved="false"></xref>.</li><li>The status code carried by the response is <xref href="IceRpc.StatusCode.NotFound" data-throw-if-not-resolved="false"></xref> and the
protocol is ice.</li><li>The request failed with an <xref href="IceRpc.IceRpcException" data-throw-if-not-resolved="false"></xref> with one of the following error:
<ul><li>The error code is <xref href="IceRpc.IceRpcError.InvocationCanceled" data-throw-if-not-resolved="false"></xref>.</li><li>The error code is <xref href="IceRpc.IceRpcError.ConnectionAborted" data-throw-if-not-resolved="false"></xref> or <xref href="IceRpc.IceRpcError.TruncatedData" data-throw-if-not-resolved="false"></xref> and the request has the <xref href="IceRpc.RequestFieldKey.Idempotent" data-throw-if-not-resolved="false"></xref>
field.</li></ul></li></ul>
<p>If the status code carried by the response is <xref href="IceRpc.StatusCode.Unavailable" data-throw-if-not-resolved="false"></xref> or <xref href="IceRpc.StatusCode.NotFound" data-throw-if-not-resolved="false"></xref> (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.</p>
Constructors
RetryInterceptor(IInvoker, RetryOptions, ILogger)
Constructs a retry interceptor.
public RetryInterceptor(IInvoker next, RetryOptions options, ILogger logger)
Parameters
nextIInvokerThe next invoker in the invocation pipeline.
optionsRetryOptionsThe options to configure the retry interceptor.
loggerILoggerThe logger.
Methods
InvokeAsync(OutgoingRequest, CancellationToken)
Sends an outgoing request and returns the corresponding incoming response.
public Task<IncomingResponse> InvokeAsync(OutgoingRequest request, CancellationToken cancellationToken)
Parameters
requestOutgoingRequestThe outgoing request being sent.
cancellationTokenCancellationTokenA 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.