Class AdaptiveRetryPolicy
The default implementation of the adaptive retry policy.
public class AdaptiveRetryPolicy : StandardRetryPolicy
- Inheritance
-
AdaptiveRetryPolicy
- Inherited Members
Constructors
AdaptiveRetryPolicy(IClientConfig)
Constructor for AdaptiveRetryPolicy.
public AdaptiveRetryPolicy(IClientConfig config)
Parameters
config
IClientConfigThe Client config object. This is used to retrieve the maximum number of retries before throwing back a exception(This does not count the initial request) and the service URL for the request.
AdaptiveRetryPolicy(int)
Constructor for AdaptiveRetryPolicy.
public AdaptiveRetryPolicy(int maxRetries)
Parameters
maxRetries
intThe maximum number of retries before throwing back a exception. This does not count the initial request.
Properties
TokenBucket
protected TokenBucket TokenBucket { get; set; }
Property Value
Methods
NotifySuccess(IExecutionContext)
Virtual method that gets called on a success Response. If its a retry success response, the entire retry acquired capacity is released(default is 5). If its just a success response a lesser value capacity is released(default is 1).
public override void NotifySuccess(IExecutionContext executionContext)
Parameters
executionContext
IExecutionContextRequest context containing the state of the request.
ObtainSendToken(IExecutionContext, Exception)
This method uses a token bucket to enforce the maximum sending rate.
public override void ObtainSendToken(IExecutionContext executionContext, Exception exception)
Parameters
executionContext
IExecutionContextThe execution context which contains both the requests and response context.
exception
ExceptionIf the prior request failed, this exception is expected to be the exception that occurred during the prior request failure.
ObtainSendTokenAsync(IExecutionContext, Exception)
This method uses a token bucket to enforce the maximum sending rate.
public override Task ObtainSendTokenAsync(IExecutionContext executionContext, Exception exception)
Parameters
executionContext
IExecutionContextThe execution context which contains both the requests and response context.
exception
ExceptionIf the prior request failed, this exception is expected to be the exception that occurred during the prior request failure.
Returns
OnRetry(IExecutionContext, bool, bool)
OnRetry is called when a retry request is initiated to determine if the request will be retried.
public override bool OnRetry(IExecutionContext executionContext, bool bypassAcquireCapacity, bool isThrottlingError)
Parameters
executionContext
IExecutionContextThe execution context which contains both the requests and response context.
bypassAcquireCapacity
booltrue to bypass any attempt to acquire capacity on a retry
isThrottlingError
booltrue if the error that will be retried is a throtting error
Returns
- bool
True if retry throttling is disabled or retry throttling is enabled and capacity can be obtained.
RetryForExceptionAsync(IExecutionContext, Exception)
Return true if the request should be retried.
public override Task<bool> RetryForExceptionAsync(IExecutionContext executionContext, Exception exception)
Parameters
executionContext
IExecutionContextRequest context containing the state of the request.
exception
ExceptionThe exception thrown by the previous request.
Returns
WaitBeforeRetryAsync(IExecutionContext)
Waits before retrying a request.
public override Task WaitBeforeRetryAsync(IExecutionContext executionContext)
Parameters
executionContext
IExecutionContextThe execution context which contains both the requests and response context.