Class RetryPolicy.Builder

java.lang.Object
com.pain001.sdk.RetryPolicy.Builder
Enclosing class:
RetryPolicy

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

    • maxAttempts

      public RetryPolicy.Builder maxAttempts(int maxAttempts)
      The number of attempts in all, including the first (default 3); 1 disables retries.
      Parameters:
      maxAttempts - at least 1
      Returns:
      this builder
    • initialBackoff

      public RetryPolicy.Builder initialBackoff(Duration initialBackoff)
      The wait before the first retry, before jitter (default 200 ms).
      Parameters:
      initialBackoff - a positive duration
      Returns:
      this builder
    • maxBackoff

      public RetryPolicy.Builder maxBackoff(Duration maxBackoff)
      The longest wait before any retry (default 5 s), and the longest Retry-After honoured.
      Parameters:
      maxBackoff - a positive duration, no shorter than the initial backoff
      Returns:
      this builder
    • build

      public RetryPolicy build()
      Builds the policy.
      Returns:
      the immutable policy
      Throws:
      IllegalArgumentException - when maxAttempts is below 1, a backoff is missing or not positive, or maxBackoff is shorter than initialBackoff