NO-ISSUE: Move End method from TxManager to Tx interface - #649
Conversation
The `End` method previously lived on the `TxManager` interface, requiring
callers to keep a reference to both the transaction manager and the
transaction in order to finish a transaction. This was unnecessary because
the `managedTx` implementation already holds a back-reference to its
manager.
This change moves `End` to the `Tx` interface so that callers can simply
call `tx.End(ctx)` instead of `manager.End(ctx, tx)`. The commit/rollback
logic that was split across `txManager.End` and `txManager.end` is now
consolidated into `managedTx.End`, which also eliminates the type-switch
dispatch and the cross-manager ownership check that were only needed
because the method accepted an arbitrary `Tx`.
Two tests that exercised the removed defensive checks ("unsupported
transaction type" and "transaction belongs to another manager") have been
removed since those scenarios can no longer arise with the new design.
All production callers, interceptor tests, and DAO/server tests have been
updated accordingly, and mocks have been regenerated.
Assisted-by: Cursor
Signed-off-by: Juan Hernandez <juan.hernandez@redhat.com>
|
@jhernand: This pull request explicitly references no jira issue. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jhernand The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Caution Review failedPull request was closed or merged during review WalkthroughThis PR refactors transaction lifecycle management by moving the ChangesTransaction Lifecycle Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Complexity: Moderate refactoring with homogeneous pattern changes across many test files, but involving a meaningful API contract change that must be verified at the core transaction manager level. Risk Assessment: Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 11✅ Passed checks (11 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
Endmethod from theTxManagerinterface to theTxinterface so thatcallers can simply call
tx.End(ctx)instead ofmanager.End(ctx, tx). ThemanagedTximplementation already holds a back-reference to its manager, so thereis no need for the transaction manager to mediate the commit/rollback decision.
txManager.EndandtxManager.endinto a singlemanagedTx.Endmethod, removingthe type-switch dispatch and the cross-manager ownership check.
regenerated mocks across 26 files.
Test plan
go build ./...compiles successfullyginkgo run -r internalpasses all 62 test suitesSummary by CodeRabbit