Interface RetryStrategy

  • All Known Implementing Classes:
    RetryStrategy.Standard

    public interface RetryStrategy
    A Strategy for performing retries. Comes with a standard implementation which follows spec
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  RetryStrategy.Standard
      A standard implementation of the RetryStrategy which follows spec based Retry-After logic - Will attempt a retry on any 301, 429, 503, or 529 response which is accompanied by a Retry-After header.
    • Method Detail

      • isRetryable

        boolean isRetryable​(HttpResponse<?> response)
        Checks to see if the response is retryable
        Parameters:
        response - the last response
        Returns:
        a bool indicating if the request should be retried
      • getWaitTime

        long getWaitTime​(HttpResponse<?> response)
        Get the number of milliseconds the system should wait before retrying. A value less than 1 will result in the termination of the retry loop
        Parameters:
        response - the last response
        Returns:
        millies
      • getMaxAttempts

        int getMaxAttempts()
        Get the max number of times the Unirest should retry responses before giving up and allowing a final return
        Returns:
        the max attempts
      • waitFor

        default void waitFor​(long millies)
        Puts the current executing thread to sleep for the specified millis
        Parameters:
        millies - sleepy time millies