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() {
  double polySum;
  switch (poly.length) {
    case 0:
      return Duration.zero;
    case 1:
      polySum = poly[0];
      break;
    default:
      polySum = poly[0];
      final attempt = attemptBackoff.attempt;
      attemptBackoff.attempt++;

      for (int i = 1; i < poly.length; i++) {
        polySum += pow(attempt, i) * poly[i];
      }
  }

  return attemptBackoff.jitter(
    Duration(microseconds: (timeUnits.inMicroseconds * polySum).round()),
    attemptBackoff.min,
    attemptBackoff.max,
    attemptBackoff.rng
  );
}