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 Details

    • THROTTLED_RETRY_AFTER_HEADER

      static final String 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

      static final Long DEFAULT_RETRY_AFTER_SECONDS
      The default amount of seconds to wait for a throttled response.
    • THROTTLED_RESPONSE_CODE

      static final int THROTTLED_RESPONSE_CODE
      The throttled HTTP response code.
      See Also:
  • Method Details

    • invoke

      RetriableCallResponse invoke(Retriable retriable)
      Executes the strategy to invoke the RetriableCallResponse call.
      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 throttled
      RequestException - if a response contains a 400-based response code value
      ResponseException - if a response contains a non 400-based response code value
    • extractRetryAfterHeaderValue

      default Long extractRetryAfterHeaderValue(okhttp3.Response response)
      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