Class ExponentialBackoffBuilderImpl

java.lang.Object
io.camunda.zeebe.client.impl.worker.ExponentialBackoffBuilderImpl
All Implemented Interfaces:
ExponentialBackoffBuilder

public final class ExponentialBackoffBuilderImpl extends Object implements ExponentialBackoffBuilder
  • Constructor Details

    • ExponentialBackoffBuilderImpl

      public ExponentialBackoffBuilderImpl()
  • Method Details

    • maxDelay

      public ExponentialBackoffBuilder maxDelay(long maxDelay)
      Description copied from interface: ExponentialBackoffBuilder
      Sets the maximum retry delay.

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

      Default is 5000ms.

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

      public ExponentialBackoffBuilder minDelay(long minDelay)
      Description copied from interface: ExponentialBackoffBuilder
      Sets the minimum retry delay.

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

      Default is 50ms.

      Specified by:
      minDelay in interface ExponentialBackoffBuilder
      Parameters:
      minDelay - the minimum delay before retrying is ms
      Returns:
      the builder for this exponential backoff
    • backoffFactor

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

      public ExponentialBackoffBuilder jitterFactor(double jitterFactor)
      Description copied from interface: ExponentialBackoffBuilder
      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

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

      public ExponentialBackoffBuilder random(Random random)
      Description copied from interface: ExponentialBackoffBuilder
      Sets the random number generator used to add jitter to the next delay.

      Default is new java.util.Random().

      Specified by:
      random in interface ExponentialBackoffBuilder
      Parameters:
      random - the random to use for jitter
      Returns:
      the builder for this exponential backoff
    • build

      public BackoffSupplier build()
      Specified by:
      build in interface ExponentialBackoffBuilder
      Returns:
      a new BackoffSupplier with the provided configuration options.