Interface BackOffDelayPolicy

All Known Implementing Classes:
BackOffDelayPolicy.FixedWithInitialDelayAndTimeoutBackOffPolicy, BackOffDelayPolicy.FixedWithInitialDelayBackOffPolicy

public interface BackOffDelayPolicy
Contract to determine a delay between attempts of some task.

The task is typically the creation of a connection.

  • Field Details

    • TIMEOUT

      static final Duration TIMEOUT
  • Method Details

    • delay

      Duration delay(int recoveryAttempt)
      Returns the delay to use for a given attempt.

      The policy can return the TIMEOUT constant to indicate that the task has reached a timeout.

      Parameters:
      recoveryAttempt - number of the recovery attempt
      Returns:
      the delay, TIMEOUT if the task should stop being retried
    • fixed

      static BackOffDelayPolicy fixed(Duration delay)
      Policy with a fixed delay.
      Parameters:
      delay - the fixed delay
      Returns:
      fixed-delay policy
    • fixedWithInitialDelay

      static BackOffDelayPolicy fixedWithInitialDelay(Duration initialDelay, Duration delay)
      Policy with an initial delay for the first attempt, then a fixed delay.
      Parameters:
      initialDelay - delay for the first attempt
      delay - delay for other attempts than the first one
      Returns:
      fixed-delay policy with initial delay
    • fixedWithInitialDelay

      static BackOffDelayPolicy fixedWithInitialDelay(Duration initialDelay, Duration delay, Duration timeout)
      Policy with an initial delay for the first attempt, then a fixed delay, and a timeout.
      Parameters:
      initialDelay - delay for the first attempt
      delay - delay for other attempts than the first one
      timeout - timeout
      Returns:
      fixed-delay policy with initial delay and timeout