Interface ExponentialBackoffBuilder

All Known Implementing Classes:
ExponentialBackoffBuilderImpl

public interface ExponentialBackoffBuilder
  • Method Details

    • maxDelay

      ExponentialBackoffBuilder maxDelay(long maxDelay)
      Sets the maximum retry delay.

      Note that the jitter may push the retry delay over this maximum.

      Default is 5000ms.

      Parameters:
      maxDelay - the maximum delay before retrying in ms
      Returns:
      the builder for this exponential backoff
    • minDelay

      ExponentialBackoffBuilder minDelay(long minDelay)
      Sets the minimum retry delay.

      Note that the jitter may push the retry delay below this minimum.

      Default is 50ms.

      Parameters:
      minDelay - the minimum delay before retrying is ms
      Returns:
      the builder for this exponential backoff
    • backoffFactor

      ExponentialBackoffBuilder backoffFactor(double backoffFactor)
      Sets the backoff multiplication factor. The previous delay is multiplied by this factor. Default is 1.6.
      Parameters:
      backoffFactor - the factor to multiply with the previous delay to determine the next delay
      Returns:
      the builder for this exponential backoff
    • jitterFactor

      ExponentialBackoffBuilder jitterFactor(double jitterFactor)
      Sets the jitter factor. The next delay is changed randomly within a range of +/- this factor.

      For example, if the next delay is calculated to be 1s and the jitterFactor is 0.1 then the actual next delay can be somewhere between 0.9 and 1.1s.

      Default is 0.1

      Parameters:
      jitterFactor - the range of possible jitter defined as a factor
      Returns:
      the builder for this exponential backoff
    • random

      Sets the random number generator used to add jitter to the next delay.

      Default is new java.util.Random().

      Parameters:
      random - the random to use for jitter
      Returns:
      the builder for this exponential backoff
    • build

      Returns:
      a new BackoffSupplier with the provided configuration options.