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 inRetryPolicy
.
-
-
Field Summary
Fields Modifier and Type Field Description static int
HTTP_STATUS_TOO_MANY_REQUESTS
HTTP response status code forToo Many Requests
.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Duration
calculateRetryDelay(int retryAttempts)
Computes the delay between each retry.int
getMaxRetries()
Max number of retry attempts to be make.default boolean
shouldRetry(HttpResponse httpResponse)
This method is consulted to determine if a retry attempt should be made for the givenHttpResponse
if the retry attempts are less thangetMaxRetries()
.default boolean
shouldRetryException(Throwable throwable)
This method is consulted to determine if a retry attempt should be made for the givenThrowable
propagated when the request failed to send.
-
-
-
Field Detail
-
HTTP_STATUS_TOO_MANY_REQUESTS
static final int HTTP_STATUS_TOO_MANY_REQUESTS
HTTP response status code forToo Many Requests
.- See Also:
- Constant Field Values
-
-
Method Detail
-
getMaxRetries
int getMaxRetries()
Max number of retry attempts to be make.- Returns:
- The max number of retry attempts.
-
calculateRetryDelay
Duration calculateRetryDelay(int retryAttempts)
Computes the delay between each retry.- Parameters:
retryAttempts
- The number of retry attempts completed so far.- Returns:
- The delay duration before the next retry.
-
shouldRetry
default boolean shouldRetry(HttpResponse httpResponse)
This method is consulted to determine if a retry attempt should be made for the givenHttpResponse
if the retry attempts are less thangetMaxRetries()
.- Parameters:
httpResponse
- The response from the previous attempt.- Returns:
- Whether a retry should be attempted.
-
shouldRetryException
default boolean shouldRetryException(Throwable throwable)
This method is consulted to determine if a retry attempt should be made for the givenThrowable
propagated when the request failed to send.- Parameters:
throwable
- TheThrowable
thrown during the previous attempt.- Returns:
- Whether a retry should be attempted.
-
-