getRetryDelay method

Duration getRetryDelay(
  1. LocusErrorType errorType
)

Calculates delay for next retry attempt.

Implementation

Duration getRetryDelay(LocusErrorType errorType) {
  final retryCount = _retryCounts[errorType] ?? 0;
  var delay = _config.retryDelay;

  // Apply exponential backoff
  for (var i = 0; i < retryCount; i++) {
    delay = Duration(
      milliseconds: (delay.inMilliseconds * _config.retryBackoff).round(),
    );
  }

  // Cap at max delay
  if (delay > _config.maxRetryDelay) {
    delay = _config.maxRetryDelay;
  }

  return delay;
}