Package com.azure.core.http.policy
Interface RetryStrategy
- All Known Implementing Classes:
ExponentialBackoff,FixedDelay
public interface RetryStrategy
The interface for determining the retry strategy used in
RetryPolicy.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intHTTP response status code forToo Many Requests. -
Method Summary
Modifier and TypeMethodDescriptioncalculateRetryDelay(int retryAttempts) Computes the delay between each retry.default DurationcalculateRetryDelay(RequestRetryCondition requestRetryCondition) Computes the delay between each retry based on theRequestRetryCondition.intMax number of retry attempts to be made.default booleanshouldRetry(HttpResponse httpResponse) This method is consulted to determine if a retry attempt should be made for the givenHttpResponseif the retry attempts are less thangetMaxRetries().default booleanshouldRetryCondition(RequestRetryCondition requestRetryCondition) This method is consulted to determine if a retry attempt should be made for the givenRequestRetryCondition.default booleanshouldRetryException(Throwable throwable) This method is consulted to determine if a retry attempt should be made for the givenThrowablepropagated when the request failed to send.
-
Field Details
-
HTTP_STATUS_TOO_MANY_REQUESTS
static final int HTTP_STATUS_TOO_MANY_REQUESTSHTTP response status code forToo Many Requests.- See Also:
-
-
Method Details
-
getMaxRetries
int getMaxRetries()Max number of retry attempts to be made.- Returns:
- The max number of retry attempts.
-
calculateRetryDelay
Computes the delay between each retry.If both this method and
calculateRetryDelay(RequestRetryCondition)are overridden, this method is ignored.- Parameters:
retryAttempts- The number of retry attempts completed so far.- Returns:
- The delay duration before the next retry.
-
calculateRetryDelay
Computes the delay between each retry based on theRequestRetryCondition.If this method is not overridden, the
calculateRetryDelay(int)method is called withRequestRetryCondition.getTryCount().If both this method and
calculateRetryDelay(int)are overridden, this method is used.- Parameters:
requestRetryCondition- TheRequestRetryConditioncontaining information that can be used to determine the delay.- Returns:
- The delay duration before the next retry.
- Throws:
NullPointerException- IfrequestRetryConditionis null.
-
shouldRetry
This method is consulted to determine if a retry attempt should be made for the givenHttpResponseif the retry attempts are less thangetMaxRetries().- Parameters:
httpResponse- The response from the previous attempt.- Returns:
- Whether a retry should be attempted.
-
shouldRetryException
This method is consulted to determine if a retry attempt should be made for the givenThrowablepropagated when the request failed to send.- Parameters:
throwable- TheThrowablethrown during the previous attempt.- Returns:
- Whether a retry should be attempted.
-
shouldRetryCondition
This method is consulted to determine if a retry attempt should be made for the givenRequestRetryCondition.By default, if the
RequestRetryConditioncontains a non-nullHttpResponse, then theshouldRetry(HttpResponse)method is called, otherwise theshouldRetryException(Throwable)method is called.- Parameters:
requestRetryCondition- TheRequestRetryConditioncontaining information that can be used to determine if the request should be retried.- Returns:
- Whether a retry should be attempted.
-