Class RetryPolicy.Builder

java.lang.Object
codes.grow.packages.betterstack.core.RetryPolicy.Builder
Enclosing class:
RetryPolicy

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

    • maxRetries

      public RetryPolicy.Builder maxRetries(int maxRetries)
      Sets the maximum number of retries.
      Parameters:
      maxRetries - retries after the first attempt, >= 0
      Returns:
      this builder
    • initialBackoff

      public RetryPolicy.Builder initialBackoff(Duration initialBackoff)
      Sets the backoff cap of the first retry.
      Parameters:
      initialBackoff - positive duration
      Returns:
      this builder
    • maxBackoff

      public RetryPolicy.Builder maxBackoff(Duration maxBackoff)
      Sets the upper bound of every backoff.
      Parameters:
      maxBackoff - positive duration
      Returns:
      this builder
    • multiplier

      public RetryPolicy.Builder multiplier(double multiplier)
      Sets the exponential growth factor.
      Parameters:
      multiplier - factor >= 1
      Returns:
      this builder
    • maxRetryAfter

      public RetryPolicy.Builder maxRetryAfter(Duration maxRetryAfter)
      Sets the longest accepted Retry-After.
      Parameters:
      maxRetryAfter - non-negative duration
      Returns:
      this builder
    • random

      public RetryPolicy.Builder random(RandomGenerator random)
      Injects the random source used for jitter (tests).
      Parameters:
      random - random generator; null restores ThreadLocalRandom
      Returns:
      this builder
    • build

      public RetryPolicy build()
      Validates and builds the policy.
      Returns:
      the policy
      Throws:
      ConfigException - when a value is out of range