-
Notifications
You must be signed in to change notification settings - Fork 54
Feature: Add Scheduled Background Job Runner #152
Copy link
Copy link
Labels
GrantFox OSSIssue tracked in GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardIssue may be eligible for a GrantFox rewardPhase 1.1API Phase 1.1 roadmap itemAPI Phase 1.1 roadmap itemThird CampaignCampaign: Third CampaignCampaign: Third Campaignbackenddevopsobservabilityworkers
Description
Activity
Metadata
Metadata
Assignees
Labels
GrantFox OSSIssue tracked in GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardIssue may be eligible for a GrantFox rewardPhase 1.1API Phase 1.1 roadmap itemAPI Phase 1.1 roadmap itemThird CampaignCampaign: Third CampaignCampaign: Third Campaignbackenddevopsobservabilityworkers
Description
Every deferred queue in the API is drained opportunistically from the request that enqueued the work, not on a schedule.
EmailService,NotificationService,WebhookService, andStellarFundingServiceeach callthis.processQueue().catch(...)immediately after enqueueing, so a row whosenextAttemptAtis in the future is only retried if unrelated traffic happens to trigger another drain. When traffic stops, retries stop, and failed deliveries can sit indefinitely. Only the account-lifecycle sweep has a real timer (setIntervalinsrc/server.ts), and its own comment notes that a dedicated worker is the intended owner.Introduce one scheduled runner process that owns every recurring queue drain, so delivery is driven by time rather than by incidental request volume, and so the work stops competing with request handling inside the API process.
File Location
learnault-api/src/workers/,learnault-api/src/server.ts,learnault-api/docker/,learnault-api/docker-compose.yml, andlearnault-api/package.jsonDesign Reference
API Roadmap Phase 1.1: Add Scheduled Background Job Runner. Builds on the leasing primitives delivered by #122.
Dependencies
Tasks
job-lease.service.tsso multiple replicas cannot double-processprocessQueue()calls from the request path, keeping enqueue synchronoussrc/server.tslifecycle sweep onto the runner and keep an opt-in flag for single-process deploymentsAcceptance Criteria
nextAttemptAtrow is picked up within one configured intervalVerification Evidence
Difficulty
Advanced