refactor: Eliminate global state in remoting config and improve architecture clarity#1031
refactor: Eliminate global state in remoting config and improve architecture clarity#1031rookiewwj wants to merge 18 commits intoapache:masterfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1031 +/- ##
=======================================
Coverage 57.66% 57.66%
=======================================
Files 267 267
Lines 17665 17658 -7
=======================================
- Hits 10187 10183 -4
+ Misses 6650 6647 -3
Partials 828 828 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
||
| // initRemoting init rpc client | ||
| func initRemoting(cfg *Config) { | ||
| seataConfig := remoteConfig.SeataConfig{ |
There was a problem hiding this comment.
I think we should keep a naming style similar to remoteConfig.SeataConfig, rather than using getty.ClientIdentity.
Getty is not equivalent to remote — getty is just one implementation of remote.
It can be understood as an abstraction, but the name itself could be changed to something more elegant.
There was a problem hiding this comment.
ok, i will change the name style similar to remoteConfig.SeataConfig
| } | ||
| } | ||
|
|
||
| func TestSeataConfig_InitAndGet(t *testing.T) { |
There was a problem hiding this comment.
You removed the old unit test code, but did not add additional tests to cover the newly added code. As a result, the current test coverage has decreased and more unit tests need to be added.
There was a problem hiding this comment.
fine, i will add more test to cover the newly code
|
Plz resolve the conflicts and re-run the |
* fix: modified version * fix: modified version * feat: remove coverage * fix: change integrate_test.sh * chore: 空提交,重新推送分支触发CI/CD --------- Co-authored-by: FengZhang <zfcode@qq.com>
Summary
This PR refactors the configuration architecture in the remoting layer by removing the problematic
SeataConfigstruct and eliminating global state, resulting in cleaner separation of concerns and improved testability.Motivation
The previous
SeataConfigdesign had several issues:ServiceVgroupMappingandServiceGrouplistwere copied from discovery config but never actually used in remotingseataConfig), making the code harder to test and maintainChanges
Removed
SeataConfigstruct from config.goseataConfigand associatedInitConfig()/GetSeataConfig()functionsAdded
ClientIdentitystruct in identity.go to represent client identity information (ApplicationID and TxServiceGroup)Modified
InitGetty()signature: now accepts*ClientIdentityinstead of*SeataConfiginitSessionManager(): updated to receive and store*ClientIdentityas an instance fieldSessionManager:clientIdentityfield to eliminate global config accessg.gettyConf.LoadBalanceTypedirectly instead of accessing global stateg.clientIdentity.TxServiceGroupfor service lookupsessionManager.clientIdentityinstead of globalGetSeataConfig()Benefits