Skip to content

feat: db is optional for the queue module#1035

Merged
hwbrzzl merged 3 commits intomasterfrom
bowen/queue-db
May 17, 2025
Merged

feat: db is optional for the queue module#1035
hwbrzzl merged 3 commits intomasterfrom
bowen/queue-db

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented May 17, 2025

📑 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

  • Added test cases for my code

@codecov
Copy link

codecov bot commented May 17, 2025

Codecov Report

Attention: Patch coverage is 75.82418% with 22 lines in your changes missing coverage. Please review.

Project coverage is 70.48%. Comparing base (e88f45b) to head (60b42ac).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
queue/worker.go 80.00% 7 Missing and 3 partials ⚠️
queue/application.go 0.00% 4 Missing ⚠️
foundation/container.go 0.00% 2 Missing and 1 partial ⚠️
queue/service_provider.go 0.00% 3 Missing ⚠️
queue/config.go 93.54% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hwbrzzl hwbrzzl marked this pull request as ready for review May 17, 2025 14:10
Copilot AI review requested due to automatic review settings May 17, 2025 14:11
@hwbrzzl hwbrzzl requested a review from a team as a code owner May 17, 2025 14:11
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 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)

Copy link
Contributor

@almas-x almas-x left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@hwbrzzl hwbrzzl merged commit c86a9f1 into master May 17, 2025
15 checks passed
@hwbrzzl hwbrzzl deleted the bowen/queue-db branch May 17, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants