Class ExponentialBackoff

java.lang.Object
io.camunda.zeebe.util.ExponentialBackoff
All Implemented Interfaces:
LongUnaryOperator

public final class ExponentialBackoff extends Object implements LongUnaryOperator
An simple implementation of exponential backoff, which multiples the previous delay with an increasing multiplier and adding some jitter to avoid multiple clients polling at the same time even with back off.

The next delay is calculated as:

 max(min(maxDelay, currentDelay * backoffFactor), minDelay) + (rand(0.0, 1.0) *
 (currentDelay * jitterFactor) + (currentDelay * -jitterFactor)) 
  • Constructor Details

    • ExponentialBackoff

      public ExponentialBackoff()
    • ExponentialBackoff

      public ExponentialBackoff(long maxDelay, long minDelay)
    • ExponentialBackoff

      public ExponentialBackoff(long maxDelay, long minDelay, double backoffFactor, double jitterFactor)
  • Method Details

    • applyAsLong

      public long applyAsLong(long operand)
      Specified by:
      applyAsLong in interface LongUnaryOperator
    • supplyRetryDelay

      public long supplyRetryDelay(long currentRetryDelay)