Skip to content

Conversation

@gusfcarvalho
Copy link
Contributor

The PR introducing digests neglected the fact a typical CCF setup will run a number of replicas of the API pod

This means notifications, emails, etc will all come up as a multiple of the number of active replicas.

This PR introduces a proper job queueing mechanism centrally defined in Postgres (with the help of river queue).

Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
Copilot AI review requested due to automatic review settings January 21, 2026 18:25
Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
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 introduces a proper job queueing mechanism using River to prevent duplicate notifications and emails in multi-replica deployments. Previously, each API pod replica would independently send emails and notifications, resulting in duplicates multiplied by the number of replicas.

Changes:

  • Adds River-based job queue backed by PostgreSQL for centralized job processing
  • Replaces direct email sending with job enqueueing in digest and auth handlers
  • Introduces worker service that processes email and digest jobs with configurable concurrency
  • Migrates digest scheduling from cron-based to River's periodic jobs

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
internal/service/worker/service.go New worker service that manages River client, workers, and job processing
internal/service/worker/jobs.go Job definitions and worker functions for email and digest processing
internal/service/worker/service_test.go Basic tests for worker service initialization
internal/config/worker.go Configuration for worker service including concurrency and retry settings
internal/config/config.go Integration of worker configuration into main config
internal/service/digest/service.go Updated to enqueue digest emails via worker service with fallback
internal/api/handler/auth/auth.go Updated to enqueue password reset emails via worker service with fallback
internal/api/handler/auth/api.go Modified to accept and pass worker service to auth handler
internal/service/scheduler/cron.go Added ParseCronNext utility function for cron parsing
cmd/run.go Initializes and starts worker service, handles circular dependency with digest service
cmd/digest.go Updated digest command to pass nil worker service
go.mod, go.sum Added River queue dependencies and updated pgx to v5.8.0
*_test.go files Updated test setup to pass nil or properly initialized services

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

Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
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

Copilot reviewed 15 out of 16 changed files in this pull request and generated 6 comments.


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

Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
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

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


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

Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
@gusfcarvalho gusfcarvalho enabled auto-merge (squash) January 21, 2026 19:35
@gusfcarvalho gusfcarvalho merged commit 733b4e6 into main Jan 21, 2026
4 checks passed
@gusfcarvalho gusfcarvalho deleted the gc-feat-proper-job-queue branch January 21, 2026 19:39
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.

2 participants