Interface Backoff

All Superinterfaces:
Function<IterationContext<?>,BackoffDelay>

public interface Backoff extends Function<IterationContext<?>,BackoffDelay>
Backoff function
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Backoff
     
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static Backoff
    exponential(Duration firstBackoff, Duration maxBackoff, int factor, boolean basedOnPreviousValue)
    Backoff function with exponential backoff delay.
    static Backoff
    fixed(Duration backoffInterval)
    Backoff function with fixed backoff delay
    static Backoff
    Backoff function with no backoff delay

    Methods inherited from interface java.util.function.Function

    andThen, apply, compose
  • Field Details

    • ZERO_BACKOFF

      static final Backoff ZERO_BACKOFF
  • Method Details

    • zero

      static Backoff zero()
      Backoff function with no backoff delay
      Returns:
      Backoff function for zero backoff delay
    • fixed

      static Backoff fixed(Duration backoffInterval)
      Backoff function with fixed backoff delay
      Parameters:
      backoffInterval - backoff interval
      Returns:
      Backoff function with fixed backoff delay
    • exponential

      static Backoff exponential(Duration firstBackoff, @Nullable Duration maxBackoff, int factor, boolean basedOnPreviousValue)
      Backoff function with exponential backoff delay. Retries are performed after a backoff interval of firstBackoff * (factor ** n) where n is the iteration. If maxBackoff is not null, the maximum backoff applied will be limited to maxBackoff.

      If basedOnPreviousValue is true, backoff will be calculated using prevBackoff * factor. When backoffs are combined with Jitter, this value will be different from the actual exponential value for the iteration.

      Parameters:
      firstBackoff - First backoff duration
      maxBackoff - Maximum backoff duration, capped to Long.MAX_VALUE milliseconds
      factor - The multiplicand for calculating backoff
      basedOnPreviousValue - If true, calculation is based on previous value which may be a backoff with jitter applied
      Returns:
      Backoff function with exponential delay