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.

See Also:
  • Field Details

    • TIMEOUT

      static final Duration TIMEOUT
  • Method Details

    • fixed

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

      static BackOffDelayPolicy fixedWithInitialDelay(Duration initialDelay, Duration delay)
      A policy with a first delay and then a constant delay.
      Parameters:
      initialDelay -
      delay -
      Returns:
      the policy with an initial delay
    • fixedWithInitialDelay

      static BackOffDelayPolicy fixedWithInitialDelay(Duration initialDelay, Duration delay, Duration timeout)
      A policy with a first delay, then a constant delay until a timeout is reached.
      Parameters:
      initialDelay -
      delay -
      timeout -
      Returns:
      the policy with an initial delay
    • 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 -
      Returns:
      the delay, TIMEOUT if the task should stop being retried