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 
    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 Summary

    Modifier and Type
    Method
    Description
    int
    Get the max number of times the Unirest should retry responses before giving up and allowing a final return
    long
    Get the number of milliseconds the system should wait before retrying.
    boolean
    Checks to see if the response is retryable
    default void
    waitFor(long millies)
    Puts the current executing thread to sleep for the specified millis
  • Method Details

    • 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