Table of Contents

Class AdaptiveRetryPolicy

Namespace
Amazon.Runtime.Internal
Assembly
AWSSDK.Core.dll

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 IClientConfig

The 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 int

The 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

TokenBucket

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 IExecutionContext

Request 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 IExecutionContext

The execution context which contains both the requests and response context.

exception Exception

If 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 IExecutionContext

The execution context which contains both the requests and response context.

exception Exception

If the prior request failed, this exception is expected to be the exception that occurred during the prior request failure.

Returns

Task

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 IExecutionContext

The execution context which contains both the requests and response context.

bypassAcquireCapacity bool

true to bypass any attempt to acquire capacity on a retry

isThrottlingError bool

true 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 IExecutionContext

Request context containing the state of the request.

exception Exception

The exception thrown by the previous request.

Returns

Task<bool>

Return true if the request should be retried.

WaitBeforeRetryAsync(IExecutionContext)

Waits before retrying a request.

public override Task WaitBeforeRetryAsync(IExecutionContext executionContext)

Parameters

executionContext IExecutionContext

The execution context which contains both the requests and response context.

Returns

Task