delay method

  1. @override
Duration delay()
override

Calculates how long the next backoff duration should be, given the prior calls to delay

Implementation

@override
Duration delay() {
  if (lastDelay < randomizedBackoff.min) {
    lastDelay = randomizedBackoff.min;
    return lastDelay;
  }

  final nextMax = (lastDelay.inMicroseconds * base).round();
  lastDelay = boundedDuration(
    Duration(microseconds: randomizedBackoff.rng.nextInt(nextMax - randomizedBackoff.min.inMicroseconds) + randomizedBackoff.min.inMicroseconds),
    randomizedBackoff.min,
    randomizedBackoff.max
  );

  return lastDelay;
}