Skip to content

refactor: remove cron scheduler in favor of pg-boss#355

Merged
SgtPooki merged 11 commits intomainfrom
refactor/only-pgboss-scheduling
Mar 17, 2026
Merged

refactor: remove cron scheduler in favor of pg-boss#355
SgtPooki merged 11 commits intomainfrom
refactor/only-pgboss-scheduling

Conversation

@silent-cipher
Copy link
Collaborator

@silent-cipher silent-cipher commented Mar 13, 2026

Another step towards #271

Summary

This PR completes the migration from the legacy in-process cron scheduler to pg-boss for all job scheduling in dealbot. The cron-based scheduler has been fully removed, making pg-boss the exclusive scheduling mechanism.

Breaking Changes

The following env variables are removed (or will be ignored if set):

  • DEALBOT_JOBS_MODE
  • DEAL_INTERVAL_SECONDS
  • RETRIEVAL_INTERVAL_SECONDS
  • DEAL_START_OFFSET_SECONDS
  • RETRIEVAL_START_OFFSET_SECONDS
  • METRICS_START_OFFSET_SECONDS

Environment Variables
The following env vars are now set with defaults (previously optional):

  • METRICS_PER_HOUR
  • DEALS_PER_SP_PER_HOUR
  • RETRIEVALS_PER_SP_PER_HOUR
  • DATASET_CREATIONS_PER_SP_PER_HOUR

API Contract
The /api/config endpoint response structure has changed:

  • Removed: scheduling.dealIntervalSeconds, scheduling.retrievalIntervalSeconds
  • Added: jobs.dealsPerSpPerHour, jobs.retrievalsPerSpPerHour, jobs.dataSetCreationsPerSpPerHour

@FilOzzy FilOzzy added this to FOC Mar 13, 2026
@github-project-automation github-project-automation bot moved this to 📌 Triage in FOC Mar 13, 2026
@silent-cipher silent-cipher self-assigned this Mar 13, 2026
@BigLep BigLep moved this from 📌 Triage to ⌨️ In Progress in FOC Mar 13, 2026
@BigLep BigLep added this to the M4.2: mainnet GA milestone Mar 13, 2026
@silent-cipher silent-cipher marked this pull request as ready for review March 16, 2026 12:42
Copilot AI review requested due to automatic review settings March 16, 2026 12:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes the backend’s migration from the legacy in-process cron scheduler to pg-boss, and updates configuration/docs/UI to reflect rate-based job scheduling and the new /api/config contract.

Changes:

  • Removed the Nest cron scheduler module/service and cron-based scheduling helpers/tests in favor of pg-boss-driven scheduling.
  • Made job rates configurable via per-hour env vars and exposed these rates via /api/config (updating the web UI/types accordingly).
  • Updated operational documentation and example configs to reflect the new scheduling model and removed env vars.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
kustomize/overlays/local/backend-configmap-local.yaml Updates local env config to rate-based scheduling (pg-boss) variables.
docs/jobs.md Removes references to DEALBOT_JOBS_MODE/cron mode and updates wording for pg-boss-only jobs.
docs/infra.md Updates infra guidance for pg-boss-only scheduling and suggested run-mode separation.
docs/environment-variables.md Removes legacy interval/offset vars; documents rate-based scheduling; updates quick reference.
apps/web/src/types/config.ts Updates config DTO type to match new /api/config contract (jobs.* rates).
apps/web/src/components/Home/Config/InfrastructureInfo.tsx Displays per-hour rates (formatted) instead of interval durations.
apps/backend/src/scheduler/scheduler.service.ts Removes legacy cron scheduler service (deleted).
apps/backend/src/scheduler/scheduler.module.ts Removes legacy scheduler module (deleted).
apps/backend/src/metrics/services/metrics-scheduler.service.ts Removes cron setup/@Cron usage; leaves methods to be invoked by pg-boss jobs.
apps/backend/src/jobs/jobs.service.ts Removes “pg-boss enabled” mode gate; enforces required per-hour rates when computing intervals.
apps/backend/src/jobs/jobs.service.spec.ts Updates tests to remove legacy scheduling config/mode assumptions.
apps/backend/src/config/app.config.ts Removes DEALBOT_JOBS_MODE, legacy interval/offset vars; requires per-hour job rate env vars.
apps/backend/src/common/utils.ts Removes cron scheduling helpers.
apps/backend/src/common/utils.spec.ts Removes tests for deleted cron helper; retains withTimeout tests.
apps/backend/src/app.module.ts Stops importing legacy SchedulerModule.
apps/backend/src/app.controller.ts Updates /api/config response shape to jobs.* rates.
apps/backend/README.md Updates backend docs to pg-boss-only scheduling and new env vars.
apps/backend/.env.example Updates example env vars for pg-boss-only scheduling (removes old scheduler mode/intervals).
Comments suppressed due to low confidence (1)

apps/backend/src/common/utils.spec.ts:6

  • The cron module mock is now unused after removing the cron scheduling helpers/tests. Consider deleting this vi.mock("cron", ...) block to reduce unnecessary dependency coupling and test noise.
// Mock the CronJob constructor - must use function syntax for constructor
vi.mock("cron", () => ({
  // biome-ignore lint/complexity/useArrowFunction: Constructor requires function syntax for 'new' operator

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@silent-cipher silent-cipher requested a review from SgtPooki March 16, 2026 13:31
Copy link
Collaborator

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only one thing needs fixing, otherwise this looks good

@SgtPooki SgtPooki merged commit 454963f into main Mar 17, 2026
6 checks passed
@SgtPooki SgtPooki deleted the refactor/only-pgboss-scheduling branch March 17, 2026 15:47
@github-project-automation github-project-automation bot moved this from ⌨️ In Progress to 🎉 Done in FOC Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

5 participants