-
Notifications
You must be signed in to change notification settings - Fork 2
feat: introduces proper job queueing #312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
There was a problem hiding this 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>
There was a problem hiding this 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>
There was a problem hiding this 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>
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).