processWithRetry method

Future<void> processWithRetry(
  1. Job job
)

Process a job with retry logic

Implementation

Future<void> processWithRetry(Job job) async {
  int attempt = 0;

  while (attempt <= maxRetries) {
    try {
      job.status = JobStatus.processing;
      await handler.handle(job);
      job.status = JobStatus.completed;
      return;
    } catch (error, stackTrace) {
      attempt++;

      if (attempt > maxRetries) {
        // Max retries reached, mark as failed
        await handler.failed(job, error, stackTrace);
        return;
      }

      // Wait before retrying (exponential backoff)
      final delay = handler.backoffDelay(attempt);
      await Future.delayed(delay);
    }
  }
}