Skip to content

Allow context to be injected for cancellation.#42

Merged
rjacobs31 merged 3 commits intomasterfrom
fix/context-cancellation-requeue
Jul 29, 2025
Merged

Allow context to be injected for cancellation.#42
rjacobs31 merged 3 commits intomasterfrom
fix/context-cancellation-requeue

Conversation

@rjacobs31
Copy link
Contributor

@rjacobs31 rjacobs31 commented Jul 29, 2025

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.

@rjacobs31 rjacobs31 requested review from HeinKalido and Copilot and removed request for Copilot July 29, 2025 12:41
Copy link

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 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

@rjacobs31 rjacobs31 merged commit a9296f3 into master Jul 29, 2025
1 check passed
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.

4 participants