feat: db is optional for the queue module#1035
Merged
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1035 +/- ##
==========================================
+ Coverage 70.40% 70.48% +0.07%
==========================================
Files 176 176
Lines 12321 12339 +18
==========================================
+ Hits 8675 8697 +22
+ Misses 3265 3261 -4
Partials 381 381 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the queue module to make the database dependency optional, improving configuration handling and error logging while updating worker management.
- Refactors NewWorker and associated functions to accept an optional db parameter.
- Updates tests and configuration to support the new optional db behavior.
- Adjusts error logging and database interaction in worker and service provider implementations.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| queue/worker_test.go | Updated tests to pass nil or valid db to NewWorker accordingly. |
| queue/worker.go | Refactored NewWorker and introduced logFailedJob for error logging. |
| queue/service_provider.go | Removed mandatory db check on bootstrapping the queue module. |
| queue/config*.go | Removed db dependency from configuration and updated test flows. |
| queue/application.go | Updated NewApplication and Worker creation to include db param. |
| mail/application_test.go | Adjusted queue initialization in mail tests per new config. |
| foundation/container.go | Added nil check for db instance. |
| foundation/application_test.go | Updated queue test setup with the new config expectations. |
| errors/list.go | Added new error definitions for job failure logging and processing. |
| database/service_provider.go | Improved error handling for building the database connection. |
| contracts/queue/config.go | Updated interface reflecting the new configuration structure. |
Comments suppressed due to low confidence (1)
queue/worker_test.go:146
- [nitpick] Consider replacing the fixed sleep with a synchronization mechanism (e.g., using channels or wait groups) to ensure that asynchronous operations complete reliably, which can improve test stability.
time.Sleep(500 * time.Millisecond)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📑 Description
This pull request introduces several changes to improve the queue system by refactoring the configuration handling, enhancing error logging, and simplifying worker management. Key updates include removing the dependency on the database interface in the queue configuration, adding new logging functionality for failed jobs, and updating the worker implementation to use the revised configuration structure.
✅ Checks