Class ExponentialBackoffRetryStrategy


  • public final class ExponentialBackoffRetryStrategy
    extends RetryStrategy
    A retry strategy with backoff parameters for calculating the exponential delay between retries.
    • Field Detail

      • DEFAULT_CLIENT_BACKOFF

        public static final int DEFAULT_CLIENT_BACKOFF
        Represents the default amount of time used when calculating a random delta in the exponential delay between retries.
        See Also:
        Constant Field Values
      • DEFAULT_MAX_BACKOFF

        public static final int DEFAULT_MAX_BACKOFF
        Represents the default maximum amount of time used when calculating the exponential delay between retries.
        See Also:
        Constant Field Values
      • DEFAULT_MIN_BACKOFF

        public static final int DEFAULT_MIN_BACKOFF
        Represents the default minimum amount of time used when calculating the exponential delay between retries.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ExponentialBackoffRetryStrategy

        public ExponentialBackoffRetryStrategy​(int retryCount,
                                               int minBackoff,
                                               int maxBackoff,
                                               int deltaBackoff)
        Initializes a new instance of the ExponentialBackoffRetryStrategy class.
        Parameters:
        retryCount - The maximum number of retry attempts.
        minBackoff - The minimum backoff time.
        maxBackoff - The maximum backoff time.
        deltaBackoff - The value that will be used to calculate a random delta in the exponential delay between retries.
      • ExponentialBackoffRetryStrategy

        public ExponentialBackoffRetryStrategy​(String name,
                                               int retryCount,
                                               int minBackoff,
                                               int maxBackoff,
                                               int deltaBackoff,
                                               boolean firstFastRetry)
        Initializes a new instance of the ExponentialBackoffRetryStrategy class.
        Parameters:
        name - The name of the retry strategy.
        retryCount - The maximum number of retry attempts.
        minBackoff - The minimum backoff time.
        maxBackoff - The maximum backoff time.
        deltaBackoff - The value that will be used to calculate a random delta in the exponential delay between retries.
        firstFastRetry - true to immediately retry in the first attempt; otherwise, false. The subsequent retries will remain subject to the configured retry interval.
    • Method Detail

      • shouldRetry

        public boolean shouldRetry​(int retryCount,
                                   okhttp3.Response response)
        Returns if a request should be retried based on the retry count, current response, and the current strategy.
        Specified by:
        shouldRetry in class RetryStrategy
        Parameters:
        retryCount - The current retry attempt count.
        response - The exception that caused the retry conditions to occur.
        Returns:
        true if the request should be retried; false otherwise.