isEligibleForRetry method

bool isEligibleForRetry([
  1. DateTime? now
])

Whether this mutation has waited out its backoff duration and is ready to be dispatched again.

Includes resilience against clock anomalies / reverse time-jumps.

Implementation

bool isEligibleForRetry([DateTime? now]) {
  final target = nextRetryAfter;
  if (target == null) return true;
  final current = now ?? DateTime.now();

  // If clock drift causes target to appear in the distant future (> 2 minutes),
  // treat the backoff as elapsed to prevent indefinitely frozen mutations.
  if (target.difference(current).inMinutes > 2) {
    return true;
  }

  return !current.isBefore(target);
}