This module provides a DB-backed retry mechanism for failed grading jobs.
How it works
- A
grading_jobstable stores failed job payloads and metadata (attempts,nextRetryAt, etc.). GradingJobServicepolls the table periodically and replays jobs by callingGradingResultService.saveResult.- Exponential backoff is used between attempts. After
maxAttemptsthe job is markedFAILED.
Configuration & running
- No external dependencies (Redis) required — the system uses the primary database (TypeORM).
- The module is auto-registered in
AppModuleand will start polling when the application boots.
Usage
- To enqueue a failed grading job from other code, inject
GradingJobServiceand callenqueueFailedJob(submissionId, payload, maxAttempts?).
Testing
- The service exposes
processOnce()for tests to trigger a single retry pass.
Notes
- Ensure
autoLoadEntitiesor explicit entity registration is enabled so TypeORM picks upGradingJobEntity. - Consider adding retention/cleanup for old failed jobs and hooks for alerting on repeated failures.