Skip to content

Conversation

@cedricve
Copy link
Member

@cedricve cedricve commented Jan 12, 2026

Description

Pull Request Title: feature/abstract-queue-options

Description:

Motivation:

The primary motivation behind this change is to introduce a more flexible and extensible architecture for queue management within our project. By abstracting queue options and client creation, we can easily support multiple queue backends in the future without significant modifications to the existing codebase. This approach enhances the project's scalability and maintainability.

Changes:

  1. Abstract Queue Options:

    • Introduced QueueOptions interface with a Validate() method to ensure each queue option type can be validated independently.
    • Implemented the Queue struct to encapsulate queue options and client interface, allowing for more flexible client creation.
  2. Unified Client Creation:

    • Added a New function in queue.go to create a new Queue instance, with support for default client creation based on the provided options.
    • Modified NewRabbitMQ function to utilize the Validate() method from RabbitOptions, ensuring consistent validation logic.
  3. Refactored Tests:

    • Updated test cases to use the new Queue struct and New function for creating queue clients.
    • Ensured proper type assertions for queue clients in test cases to maintain backward compatibility.

Benefits:

  • Flexibility: The new abstraction allows for easy integration of different types of queue systems (e.g., RabbitMQ, Kafka) by simply implementing the QueueOptions and QueueInterface.
  • Maintainability: Centralizing the client creation logic reduces redundancy and potential errors, making the codebase easier to maintain and extend.
  • Consistency: Uniform validation through the QueueOptions interface ensures that all queue configurations are validated consistently.

Overall, this change significantly improves the project's architecture, paving the way for future enhancements and integrations with minimal disruption.

Introduces a generic Queue struct and New() constructor to abstract queue client creation, supporting dependency injection for testing. Moves RabbitOptions validation to a method and updates tests to use the new Queue interface, improving modularity and testability.
@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

❌ Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/queue/queue.go 71.42% 3 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@cedricve cedricve merged commit b0f319b into main Jan 12, 2026
6 checks passed
@cedricve cedricve deleted the feature/abstract-queue-options branch January 12, 2026 20:51
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