Class DefaultRetryPolicy
The default implementation of the legacy retry policy.
public class DefaultRetryPolicy : RetryPolicy
- Inheritance
-
DefaultRetryPolicy
- Inherited Members
Constructors
DefaultRetryPolicy(IClientConfig)
Constructor for DefaultRetryPolicy.
public DefaultRetryPolicy(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.
DefaultRetryPolicy(int)
Constructor for DefaultRetryPolicy.
public DefaultRetryPolicy(int maxRetries)
Parameters
maxRetries
intThe maximum number of retries before throwing back a exception. This does not count the initial request.
Properties
MaxBackoffInMilliseconds
The maximum value of exponential backoff in milliseconds, which will be used to wait before retrying a request. The default is 30000 milliseconds.
public int MaxBackoffInMilliseconds { get; set; }
Property Value
Methods
CanRetry(IExecutionContext)
Returns true if the request is in a state where it can be retried, else false.
public override bool CanRetry(IExecutionContext executionContext)
Parameters
executionContext
IExecutionContextRequest context containing the state of the request.
Returns
- bool
Returns true if the request is in a state where it can be retried, else false.
ContainErrorMessage(Exception)
[Obsolete("This method is no longer used within DefaultRetryPolicy")]
protected static bool ContainErrorMessage(Exception exception)
Parameters
exception
Exception
Returns
IsInnerException<T>(Exception)
[Obsolete("This method has been moved to AWSSDK.Runtime.Internal.Util.ExceptionUtils")]
protected static bool IsInnerException<T>(Exception exception) where T : Exception
Parameters
exception
Exception
Returns
Type Parameters
T
IsInnerException<T>(Exception, out T)
[Obsolete("This method has been moved to AWSSDK.Runtime.Internal.Util.ExceptionUtils")]
protected static bool IsInnerException<T>(Exception exception, out T inner) where T : Exception
Parameters
exception
Exceptioninner
T
Returns
Type Parameters
T
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.
OnRetry(IExecutionContext)
Virtual method that gets called when a retry request is initiated. If retry throttling is enabled, the value returned is true if the required capacity is retured, false otherwise. If retry throttling is disabled, true is returned.
public override bool OnRetry(IExecutionContext executionContext)
Parameters
executionContext
IExecutionContextThe execution context which contains both the requests and response context.
Returns
OnRetry(IExecutionContext, bool)
Virtual method that gets called when a retry request is initiated. If retry throttling is enabled, the value returned is true if the required capacity is retured, false otherwise. If retry throttling is disabled, true is returned.
public override bool OnRetry(IExecutionContext executionContext, bool bypassAcquireCapacity)
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
Returns
OnRetry(IExecutionContext, bool, bool)
Virtual method that gets called when a retry request is initiated. If retry throttling is enabled, the value returned is true if the required capacity is retured, false otherwise. If retry throttling is disabled, true is returned.
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
RetryForException(IExecutionContext, Exception)
Return true if the request should be retried.
public override bool RetryForException(IExecutionContext executionContext, Exception exception)
Parameters
executionContext
IExecutionContextRequest context containing the state of the request.
exception
ExceptionThe exception thrown by the previous request.
Returns
- bool
Return true if the request should be retried.
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
RetryLimitReached(IExecutionContext)
Checks if the retry limit is reached.
public override bool RetryLimitReached(IExecutionContext executionContext)
Parameters
executionContext
IExecutionContextRequest context containing the state of the request.
Returns
- bool
Return false if the request can be retried, based on number of retries.
WaitBeforeRetry(IExecutionContext)
Waits before retrying a request. The default policy implements a exponential backoff.
public override void WaitBeforeRetry(IExecutionContext executionContext)
Parameters
executionContext
IExecutionContextRequest context containing the state of the request.
WaitBeforeRetry(int, int)
Waits for an amount of time using an exponential backoff algorithm.
public static void WaitBeforeRetry(int retries, int maxBackoffInMilliseconds)
Parameters
retries
intThe request retry index. The first request is expected to be 0 while the first retry will be 1.
maxBackoffInMilliseconds
intThe max number of milliseconds to wait
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.