rookiewwj opened a new pull request, #1031:
URL: https://github.com/apache/incubator-seata-go/pull/1031
### Summary
This PR refactors the configuration architecture in the remoting layer by
removing the problematic `SeataConfig` struct and eliminating global state,
resulting in cleaner separation of concerns and improved testability.
### Motivation
The previous `SeataConfig` design had several issues:
1. **Mixed responsibilities**: Combined configurations from different layers
(remoting, discovery, and getty) into a single struct
2. **Redundant fields**: `ServiceVgroupMapping` and `ServiceGrouplist` were
copied from discovery config but never actually used in remoting
3. **Global state**: Configuration was stored in a global variable
(`seataConfig`), making the code harder to test and maintain
4. **Unclear data flow**: Dependencies between modules were obscured by
global variable access
### Changes
#### Removed
- `SeataConfig` struct from config.go
- Global variable `seataConfig` and associated `InitConfig()` /
`GetSeataConfig()` functions
- Unnecessary configuration copying in client.go
- Tests for removed functionality
#### Added
- New `ClientIdentity` struct in identity.go to represent client identity
information (ApplicationID and TxServiceGroup)
#### Modified
- `InitGetty()` signature: now accepts `*ClientIdentity` instead of
`*SeataConfig`
- `initSessionManager()`: updated to receive and store `*ClientIdentity` as
an instance field
- `SessionManager`:
- Added `clientIdentity` field to eliminate global config access
- Now uses `g.gettyConf.LoadBalanceType` directly instead of accessing
global state
- Uses `g.clientIdentity.TxServiceGroup` for service lookup
- listener.go: accesses `sessionManager.clientIdentity` instead of global
`GetSeataConfig()`
### Benefits
- ✅ **Better separation of concerns**: Each layer manages its own
configuration
- ✅ **No global state**: All dependencies are passed explicitly, improving
testability
- ✅ **Cleaner data flow**: Configuration flows directly from client
initialization to the components that need it
- ✅ **Reduced coupling**: Modules no longer depend on a centralized global
configuration
- ✅ **Code size reduction**: Net reduction of 62 lines of code
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]