Interface RetryStrategy
- All Known Implementing Classes:
ExponentialDelayRetryStrategy, FixedDelayRetryStrategy, NoRetryStrategy
public interface RetryStrategy
Defines the interface for a retry strategy that enables different approaches to determine how and when
to retry an invocation.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault LongextractRetryAfterHeaderValue(okhttp3.Response response) Extracts the defined throttle retry value from the response header, or the default if none is defined.Executes the strategy to invoke theRetriableCallResponsecall.default voidvalidateResponseCode(okhttp3.Response response) Validates the response code for a response.
-
Field Details
-
THROTTLED_RETRY_AFTER_HEADER
The HTTP header for the number of seconds to wait for a retry when an invocation is throttled.- See Also:
-
DEFAULT_RETRY_AFTER_SECONDS
The default amount of seconds to wait for a throttled response. -
THROTTLED_RESPONSE_CODE
static final int THROTTLED_RESPONSE_CODEThe throttled HTTP response code.- See Also:
-
-
Method Details
-
invoke
Executes the strategy to invoke theRetriableCallResponsecall.- Parameters:
retriable- the call to invoke- Returns:
- the response
-
validateResponseCode
default void validateResponseCode(okhttp3.Response response) Validates the response code for a response.- Parameters:
response- the response to evaluate- Throws:
ThrottledException- if a response was throttledRequestException- if a response contains a 400-based response code valueResponseException- if a response contains a non 400-based response code value
-
extractRetryAfterHeaderValue
Extracts the defined throttle retry value from the response header, or the default if none is defined.- Parameters:
response- the response- Returns:
- the amount of time in seconds to wait before the next retry
-