Allow context to be injected for cancellation.#42
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces context injection for cancellation support in the rabbit-events library. The main purpose is to enable proper shutdown of event channels by allowing external contexts to be injected and cancelled when the stop() function is called.
- Added context injection capability through
WithContext()option in RabbitExchange - Updated all test files to use proper context handling and cleanup patterns
- Migrated from golang/mock to go.uber.org/mock for better Go module compatibility
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| exchange.go | Added context support with cancellation handling for receive operations |
| test/util_test.go | New utility functions for test setup and cleanup |
| test/rabbit_events_test.go | Updated tests to use context injection and proper cleanup patterns |
| test/auto_generated_rabbitGenMock.go | Regenerated mocks using go.uber.org/mock |
| rabbit_events_suite_test.go | Updated import naming for consistency |
| rabbit.go | Minor formatting improvements and type definition restructuring |
| go.mod | Updated dependencies from golang/mock to go.uber.org/mock |
| events_test.go | Minor formatting cleanup |
| events.go | Code formatting improvements and function signature alignment |
| errors.go | Fixed typo in comment |
HeinKalido
approved these changes
Jul 29, 2025
Himanshujk
approved these changes
Jul 29, 2025
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.
We need properly handle an event channel being stopped. The easiest way to do that is to inject a context and to cancel that context when the
stop()function is called.This should also behave correctly when no external context is passed in, although one loses the ability to have an entire server shut down by cancelling a single context.
Edit: Only the second commit has actually changed functionality.