Skip to content

feat(workers): schedule billing reconciliation workers alongside other jobs - #1479

Open
lienhoatienphung-svg wants to merge 1 commit into
CalloraOrg:mainfrom
lienhoatienphung-svg:feat/1214-schedule-billing-reconciliation-worker
Open

lienhoatienphung-svg wants to merge 1 commit into
CalloraOrg:mainfrom
lienhoatienphung-svg:feat/1214-schedule-billing-reconciliation-worker

Conversation

@lienhoatienphung-svg

Copy link
Copy Markdown

Closes #1214

Summary

Adds BILLING_RECON_INTERVAL_MS, BILLING_RECON_BATCH_SIZE, and BILLING_RECON_GRACE_PERIOD_MS configuration in src/config/env.ts and src/config/index.ts, adds createPostgresReconciliationStore and batchSize/gracePeriodMs options in src/services/billingReconciliationJob.ts, and wires billingReconJob into src/index.ts startup (startServer), graceful shutdown (shutdownSubsystems), and resource cleanup (closeAllDataResources).

Acceptance Criteria Mapping

  • BillingReconciliationJob is started when the server boots and stopped during graceful shutdown: Registered in shutdownSubsystems, closeAllDataResources, and startServer in src/index.ts.
  • Reconciliation runs are persisted to reconciliation_runs via a Postgres store: Implemented createPostgresReconciliationStore(db) in src/services/billingReconciliationJob.ts.
  • Interval, batch size, and grace period are configurable via environment variables with sensible defaults: Added BILLING_RECON_INTERVAL_MS, BILLING_RECON_BATCH_SIZE, and BILLING_RECON_GRACE_PERIOD_MS.
  • Unit tests cover the scheduled lifecycle and graceful drain: Verified in src/services/billingReconciliationJob.test.ts.

Validation

  • npx jest src/services/billingReconciliationJob.test.ts --no-cache (all 13 tests pass).

Payout Wallet (Base Mainnet USDC / EVM): 0x3806cd592a508d1992Ed007C2F53de251C2E7452

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Schedule billing reconciliation workers alongside other jobs

1 participant