Interface BackoffStrategy

    • Method Detail

      • computeDelay

        Duration computeDelay​(int attempt)
        Compute the amount of time to wait before the provided attempt number is executed.
        Parameters:
        attempt - The attempt to compute the delay for, starting at one.
        Throws:
        IllegalArgumentException - If the given attempt is less or equal to zero.
      • retryImmediately

        static BackoffStrategy retryImmediately()
        Do not back off: retry immediately.
      • fixedDelay

        static BackoffStrategy fixedDelay​(Duration delay)
        Wait for a random period of time between 0ms and the provided delay.
      • fixedDelayWithoutJitter

        static BackoffStrategy fixedDelayWithoutJitter​(Duration delay)
        Wait for a period of time equal to the provided delay.
      • exponentialDelay

        static BackoffStrategy exponentialDelay​(Duration baseDelay,
                                                Duration maxDelay)
        Wait for a random period of time between 0ms and an exponentially increasing amount of time between each subsequent attempt of the same call.

        Specifically, the first attempt waits 0ms, and each subsequent attempt waits between 0ms and min(maxDelay, baseDelay * (1 << (attempt - 2))).

      • exponentialDelayHalfJitter

        static BackoffStrategy exponentialDelayHalfJitter​(Duration baseDelay,
                                                          Duration maxDelay)
        Wait for a random period of time with an upper bound of exponentially increasing amount of time between each subsequent attempt of the same call and a lower bound of half the amount of the computed exponential delay.

        Specifically, the first attempt waits 0ms, and each subsequent attempt waits between min(maxDelay, baseDelay * (1 << (attempt - 2))) / 2 and min(maxDelay, baseDelay * (1 << (attempt - 2))) + 1.

      • exponentialDelayWithoutJitter

        static BackoffStrategy exponentialDelayWithoutJitter​(Duration baseDelay,
                                                             Duration maxDelay)
        Wait for an exponentially increasing amount of time between each subsequent attempt of the same call.

        Specifically, the first attempt waits 0ms, and each subsequent attempt waits for min(maxDelay, baseDelay * (1 << (attempt - 2))).