feat: use exchange mechanism#72
Merged
Merged
Conversation
cbartz
commented
Jan 6, 2026
cbartz
commented
Jan 6, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an explicit exchange mechanism for RabbitMQ message routing, replacing the default exchange pattern. The publisher (webhook-gateway) now declares only an exchange, while the consumer (planner) declares the queue and binds it to the exchange, following AMQP best practices for publisher-consumer decoupling.
Key Changes:
- Introduced
QueueConfigstruct to centralize exchange, queue, and routing key configuration - Updated publisher to declare exchanges instead of queues
- Modified consumer to declare queues and bind them to exchanges
- Refactored mock objects into a dedicated test file for better organization
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/queue/config.go | New file defining QueueConfig struct and default configuration values |
| internal/queue/types.go | Refactored channel reset logic and added exchange/queue declaration and binding methods |
| internal/queue/producer.go | Updated to use QueueConfig and publish to exchange instead of default exchange |
| internal/queue/consumer.go | Modified to declare exchange, queue, and binding during channel setup |
| internal/queue/mock_test.go | Consolidated mock implementations into a dedicated test file |
| internal/queue/producer_test.go | Updated tests to use QueueConfig and new mock structure |
| internal/queue/consumer_test.go | Updated tests to use QueueConfig and new mock structure |
| internal/queue/types_test.go | Removed old mock implementations (moved to mock_test.go) |
| internal/planner/consumer.go | Updated to accept QueueConfig parameter |
| cmd/webhook-gateway/main.go | Updated to use DefaultQueueConfig() |
| cmd/webhook-gateway/webhook_test.go | Added queue setup to ensure exchange and queue exist before publishing |
| cmd/planner/main.go | Updated to use DefaultQueueConfig() |
| cmd/planner/main_test.go | Updated to declare exchange and bind queue in tests |
| CONTRIBUTING.md | Updated integration test commands with corrected syntax |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
3 tasks
weiiwang01
approved these changes
Jan 7, 2026
yanksyoon
reviewed
Jan 7, 2026
3 tasks
Contributor
|
@yanksyoon I've opened a new pull request, #78, to work on those changes. Once the pull request is ready, I'll request review from you. |
yhaliaw
approved these changes
Jan 8, 2026
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.
Overview
Use an explicit exchange instead of the default exchange for publishing messages.
The publisher (webhook-gateway) will now only declare a an exchange (with type direct).
The consumer (planner) will declare the queue and bind the exchange to the queue. To avoid errors when the exchange is not declared yet (e.g. the webhook-gateway has not been deployed yet), it will again declare the exchange. This is safe, as it is an idempotent operation.
Semantic change : If the webhook-gateway gets deployed without the planner, no messages will be stored, as there is no queue bound to the exchange.
Rationale
Having the publisher (webhook-gateway) publishing to an exchange without declaring the queue decouples the publisher from the queue and adheres to best practices.
Checklist
CONTRIBUTING.mdhas been updated upon changes to the contribution/development process (e.g. changes to the way tests are run)No need for TA, for minor technical doc update.