Class RetryStrategy

  • Direct Known Subclasses:
    ExponentialBackoffRetryStrategy

    public abstract class RetryStrategy
    extends Object
    Represents a retry strategy that determines the number of retry attempts and the interval between retries.
    • Field Detail

      • DEFAULT_CLIENT_RETRY_COUNT

        public static final int DEFAULT_CLIENT_RETRY_COUNT
        Represents the default number of retry attempts.
        See Also:
        Constant Field Values
      • DEFAULT_RETRY_INTERVAL

        public static final int DEFAULT_RETRY_INTERVAL
        Represents the default interval between retries.
        See Also:
        Constant Field Values
      • DEFAULT_FIRST_FAST_RETRY

        public static final boolean DEFAULT_FIRST_FAST_RETRY
        Represents the default flag indicating whether the first retry attempt will be made immediately, whereas subsequent retries will remain subject to the retry interval.
        See Also:
        Constant Field Values
    • Constructor Detail

      • RetryStrategy

        protected RetryStrategy​(String name,
                                boolean firstFastRetry)
        Initializes a new instance of the RetryStrategy class.
        Parameters:
        name - The name of the retry strategy.
        firstFastRetry - true to immediately retry in the first attempt; otherwise, false.
    • Method Detail

      • shouldRetry

        public abstract 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.
        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.
      • name

        public String name()
        Gets the name of the retry strategy.
        Returns:
        the name of the retry strategy.
      • isFastFirstRetry

        public boolean isFastFirstRetry()
        Gets whether the first retry attempt will be made immediately.
        Returns:
        true if the first retry attempt will be made immediately. false otherwise.