Class RetryNetworkFunc<T>

java.lang.Object
org.filestack.internal.RetryNetworkFunc<T>
Type Parameters:
T - type of object to return

public abstract class RetryNetworkFunc<T> extends Object
Abstract class to generalize retry logic of a network call.
  • Constructor Details

    • RetryNetworkFunc

      public RetryNetworkFunc(int maxNetworkRetries, int maxServerRetries, int delayBase)
      Constructs an instance following the given settings. The network call is made in work(). Override process(Response) to customize parsing the response.
      Parameters:
      maxNetworkRetries - times to retry after a network failure
      maxServerRetries - times to retry after an error response from the server
      delayBase - base for exponential backoff, delay (seconds) == base ^ retryCount
  • Method Details

    • call

      public T call() throws Exception
      Start the request.
      Throws:
      Exception
    • onNetworkFail

      public void onNetworkFail(int retries) throws Exception
      Called for network failures.
      Throws:
      Exception
    • onServerFail

      public void onServerFail(int retries) throws Exception
      Called for server failures.
      Throws:
      Exception
    • getNetworkRetries

      public int getNetworkRetries()
    • getServerRetries

      public int getServerRetries()