AZSRetryPolicyExponential Class Reference

Inherits from NSObject
Conforms to AZSRetryPolicy
Declared in AZSRetryPolicy.h
AZSRetryPolicy.m

Overview

A retry policy with an exponentially increasing wait time between retries.

This policy will evaluate whether or not the request should be retried depending on the HTTP status code of the response. If the status code indicates that the request should be retried, it will specify an exponentially increasing wait time (each retry will wait roughly twice as long as the prior one.) This policy has a hard-coded minimum of 0.01 seconds, and maximum of 120 seconds, regardless of retry count or backOffDelta.

Time intervals are slightly randomized.

This should be the default policy for most operations. This policy works best when the service is throttling an account due to overuse.

Other Methods

  maxAttempts

The maximum number of retries the policy will allow.

@property NSInteger maxAttempts

Discussion

The maximum number of retries the policy will allow.

Declared In

AZSRetryPolicy.h

  averageBackoffDelta

The average wait time for the first retry (other than the randomization). For example, if this is set to 3 seconds, then the first retry will wait roughly 3 seconds. The second will wait 6, the third 12, the fourth 24, etc.

@property NSTimeInterval averageBackoffDelta

Discussion

The average wait time for the first retry (other than the randomization). For example, if this is set to 3 seconds, then the first retry will wait roughly 3 seconds. The second will wait 6, the third 12, the fourth 24, etc.

Declared In

AZSRetryPolicy.h

– init

Initializes a fresh instance of the exponential retry policy.

- (instancetype)init

Return Value

The newly allocated instance.

Discussion

Initializes a fresh instance of the exponential retry policy.

Declared In

AZSRetryPolicy.h

– initWithMaxAttempts:averageBackoffDelta:

Initializes a fresh instance of the exponential retry policy.

- (instancetype)initWithMaxAttempts:(NSInteger)maxAttempts averageBackoffDelta:(NSTimeInterval)averageBackoffDelta

Parameters

maxAttempts

The maximum number of retries the policy will allow.

averageBackoffDelta

The time the retry policy will specify to wait between retries, for the first retry. Afterwards, time will roughly double with each retry.

Return Value

The newly allocated instance.

Discussion

Initializes a fresh instance of the exponential retry policy.

Declared In

AZSRetryPolicy.h

Other Methods

– evaluateRetryContext:withOperationContext:

The method that evaluates the RetryContext to determine if the request should be retried or not.

- (AZSRetryInfo *)evaluateRetryContext:(AZSRetryContext *)retryContext withOperationContext:(AZSOperationContext *)operationContext

Parameters

retryContext

The AZSRetryContext containing information about the most recent request.

operationContext

The AZSOperationContext for the entire operation thus far.

Return Value

An AZSRetryInfo object that contains whether or not the request should be retried, and if so, how long to wait until the next trial.

Discussion

The method that evaluates the RetryContext to determine if the request should be retried or not.

Declared In

AZSRetryPolicy.h

– clone

Clone this retry policy. Required internally in the library. Must return a fresh instance with the same parameters.

- (id<AZSRetryPolicy>)clone

Return Value

The cloned retry policy.

Discussion

Clone this retry policy. Required internally in the library. Must return a fresh instance with the same parameters.

Declared In

AZSRetryPolicy.h