delay method

Duration delay(
  1. int attempt
)

Delay after attempt number of attempts.

This is computed as pow(2, attempt) * delayFactor, then is multiplied by between -randomizationFactor and randomizationFactor at random.

Implementation

Duration delay(int attempt) {
  assert(attempt >= 0, 'attempt cannot be negative');
  if (attempt <= 0) {
    return Duration.zero;
  }
  final rf = (randomizationFactor * (_rand.nextDouble() * 2 - 1) + 1);
  final delay = (delayFactor * math.pow(2, attempt) * rf);
  return delay < maxDelay ? delay : maxDelay;
}