Interface RetryPolicy.Backoff

Enclosing class:
RetryPolicy
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

Determines how long to wait before retrying after a failed attempt.

Implementations should be thread-safe if the RetryPolicy is shared across threads.

Since:
4.4.0
Author:
Mark Allen
  • Method Details

    • delayAfterFailedAttempt

      Determines how long to wait after a failed attempt before the next retry.
      Parameters:
      failedAttemptNumber - one-based number of the attempt that just failed
      failure - the database failure that caused the attempt to fail
      Returns:
      delay before the next retry
    • fixed

      Creates a fixed backoff.
      Parameters:
      delay - delay before every retry
      Returns:
      a fixed backoff
    • fullJitter

      Randomizes a delegate's delay uniformly at nanosecond resolution from zero (inclusive) to its cap (exclusive). A zero cap remains zero. This is useful for spreading simultaneous retries across clients. The delegate must return a non-null, nonnegative duration and be thread-safe when shared.
      Parameters:
      delegate - backoff supplying the delay cap
      Returns:
      a backoff with full jitter
      Since:
      4.8.0
    • exponential

      Creates an exponential backoff.

      Failed attempt 1 returns initialDelay, failed attempt 2 returns initialDelay * 2, failed attempt 3 returns initialDelay * 4, and so on until the delay reaches maxDelay. Arithmetic overflow saturates at maxDelay.

      Parameters:
      initialDelay - initial delay
      maxDelay - maximum delay
      Returns:
      an exponential backoff