Class RetryConfig.Builder

java.lang.Object
com.shri.restinpeace.RetryConfig.Builder
Enclosing class:
RetryConfig

public static final class RetryConfig.Builder extends Object
Builds a RetryConfig.
  • Method Details

    • times

      public RetryConfig.Builder times(int times)
      Sets the maximum number of attempts in total.
      Parameters:
      times - the maximum number of attempts; must be at least 1
      Returns:
      this builder
    • delayMillis

      public RetryConfig.Builder delayMillis(long delayMillis)
      Sets how long to wait before the first retry.
      Parameters:
      delayMillis - the initial delay in milliseconds
      Returns:
      this builder
    • backoffMultiplier

      public RetryConfig.Builder backoffMultiplier(double backoffMultiplier)
      Sets the factor the delay is multiplied by after each retry.
      Parameters:
      backoffMultiplier - the backoff multiplier
      Returns:
      this builder
    • jitterFactor

      public RetryConfig.Builder jitterFactor(double jitterFactor)
      Sets the jitter fraction applied to each computed delay.
      Parameters:
      jitterFactor - the jitter fraction; must be between 0.0 and 1.0 inclusive
      Returns:
      this builder
    • retryOnStatus

      public RetryConfig.Builder retryOnStatus(int... retryOnStatus)
      Sets the HTTP status codes that count as a failure worth retrying.
      Parameters:
      retryOnStatus - the retryable status codes
      Returns:
      this builder
    • idempotent

      public RetryConfig.Builder idempotent(boolean idempotent)
      Sets whether to send a stable Idempotency-Key.
      Parameters:
      idempotent - whether to send a stable Idempotency-Key
      Returns:
      this builder
    • build

      public RetryConfig build()
      Builds the config.
      Returns:
      the built config