Class RetryInterceptor.Builder

java.lang.Object
com.helixframework.okhttp.retry.RetryInterceptor.Builder
Enclosing class:
RetryInterceptor

public static class RetryInterceptor.Builder extends Object
Builder for creating new instances of RetryInterceptor.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • maxRetries

      public RetryInterceptor.Builder maxRetries(int maxRetries)
      Sets the maximum number of retries to execute before returning a failed response.

      This is an optional setting and defaults to '3'.

      Parameters:
      maxRetries - maximum number of retries
      Returns:
      RetryInterceptor.Builder
    • initialBackoff

      public RetryInterceptor.Builder initialBackoff(long initialBackoff)
      Sets the number of milliseconds to initially wait before executing the first retry.

      This is an optional setting and defaults to '50'.

      Parameters:
      initialBackoff - number of milliseconds to initially wait for backoff
      Returns:
      RetryInterceptor.Builder
    • retryOn

      public RetryInterceptor.Builder retryOn(Predicate<okhttp3.Response> retryOn)
      Predicate that determines if the request should be retried.

      This is an optional setting and defaults to retrying any request with a 500 series http status code.

      Parameters:
      retryOn - predicate to determine if the request should be retried
      Returns:
      RetryInterceptor.Builder
    • build

      public RetryInterceptor build()
      Creates a new instance of RetryInterceptor.
      Returns:
      a RetryInterceptor
      Throws:
      IllegalArgumentException - when validation of the builder parameters fails