Class FeatureFetchRetryPolicy

java.lang.Object
growthbook.sdk.java.retry.FeatureFetchRetryPolicy

public class FeatureFetchRetryPolicy extends Object
Configures bounded exponential backoff for feature fetch requests.

The default policy allows five total attempts. Delays are calculated before each retry, so the default five attempts produce retry waits of 1s, 2s, 4s, and 8s. The 16s default maximum delay caps custom policies with more attempts.

  • Field Details

    • DEFAULT_MAX_ATTEMPTS

      public static final int DEFAULT_MAX_ATTEMPTS
      See Also:
    • DEFAULT_MAX_DELAY

      public static final Duration DEFAULT_MAX_DELAY
    • DEFAULT_INITIAL_DELAY

      public static final Duration DEFAULT_INITIAL_DELAY
  • Constructor Details

    • FeatureFetchRetryPolicy

      public FeatureFetchRetryPolicy()
    • FeatureFetchRetryPolicy

      public FeatureFetchRetryPolicy(int maxAttempts, Duration initialDelay, Duration maxDelay)
      Creates an exponential backoff policy.
      Parameters:
      maxAttempts - total attempts, including the first attempt
      initialDelay - delay before the first retry
      maxDelay - upper bound for any retry delay
  • Method Details

    • getDelayMillisBeforeAttempt

      public long getDelayMillisBeforeAttempt(int attemptNumber)
      Returns the delay before the requested attempt number.
      Parameters:
      attemptNumber - one-based attempt number
      Returns:
      zero for the first attempt, otherwise the capped exponential delay
    • getMaxAttempts

      public int getMaxAttempts()
    • getMaxDelay

      public Duration getMaxDelay()
    • getInitialDelay

      public Duration getInitialDelay()