-
Notifications
You must be signed in to change notification settings - Fork 0
Transaction management updates #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #87 +/- ##
==========================================
- Coverage 97.16% 96.95% -0.22%
==========================================
Files 18 19 +1
Lines 2363 2492 +129
==========================================
+ Hits 2296 2416 +120
- Misses 55 61 +6
- Partials 12 15 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
… reducing code duplication
…types and simplifying assertions
…egistration scenarios
- Added validation logic to ensure that if any transaction is enabled (global, sub-router, or route level), a TransactionFactory must be provided. - Introduced panic scenarios for invalid configurations to prevent router startup with missing TransactionFactory. - Created comprehensive tests to cover various transaction validation scenarios, including global, sub-router, and route-level configurations. - Ensured that dynamically registered sub-routers bypass validation checks, maintaining expected behavior. - Updated existing tests to reflect changes in handler registration to use http.HandlerFunc consistently. - Removed unused responseWriter type and related tests to streamline codebase.
There was a problem hiding this 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 adds support for automatic transaction management across the router by introducing a TransactionFactory, extending configs, updating examples/tests, and providing mock implementations.
- Introduce
TransactionFactoryinterface andTransactionConfigoverrides in common and router configurations - Add mock transaction types and extend tests/examples to cover transaction flows
- Update existing route registration calls to include the new transaction override parameter
Reviewed Changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/router/internal/mocks/transaction_mocks.go | Add mock implementations (MockTransaction, MockTransactionFactory, ErrorTransactionFactory) for testing transactions |
| pkg/router/config.go | Add GlobalTransaction and TransactionFactory fields to RouterConfig for transaction management |
| pkg/common/types.go | Define the TransactionFactory interface |
| pkg/common/config.go | Introduce TransactionConfig, HasTransaction, and route-level overrides |
| pkg/router/integration_test.go | Update integration tests to pass the new transaction argument |
| pkg/router/handler_func_coverage_test.go | Add tests for handler-to-HandlerFunc conversion (missing type) |
| examples/... | Update examples to include the extra nil transaction parameter |
Comments suppressed due to low confidence (1)
pkg/router/handler_func_coverage_test.go:36
- The type
customHandleris not defined in this file, causing a compilation error. DefinecustomHandlerlocally in this test or import it from another package.
customHandler := &customHandler{}
| m.BeginCount++ | ||
| m.mu.Unlock() |
Copilot
AI
Jun 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider using defer m.mu.Unlock() immediately after locking to ensure the mutex is always released, even if the function is extended in the future.
| m.BeginCount++ | |
| m.mu.Unlock() | |
| defer m.mu.Unlock() | |
| m.BeginCount++ |
No description provided.