Using global to replace config in protocol#3054
Using global to replace config in protocol#3054nanjiek wants to merge 31 commits intoapache:developfrom
Conversation
…: undefined: protocol (typecheck)
…ix protocol tests
1. Where the error occursThe error happens in if rawConfig, err := bcl.dynamicConfiguration.GetRule(key,
config_center.WithGroup(constant.Dubbo)); err != nil {
bcl.configurators = []config_center.Configurator{}
return
} else if len(rawConfig) > 0 {
if err := bcl.genConfiguratorFromRawRule(rawConfig); err != nil {
logger.Error("bcl.genConfiguratorFromRawRule(rawConfig:%v) = error:%v", rawConfig, err)
}
}2. Root cause — configuration format mismatchThe core issue is a format mismatch. In dynamicConfiguration.content = `
dubbo.consumer.request_timeout=5s
dubbo.consumer.connect_timeout=5s
dubbo.application.organization=ikurento.com
...
`However, in func (parser *DefaultConfigurationParser) ParseToUrls(content string) ([]*common.URL, error) {
config := ConfiguratorConfig{}
if err := yaml.Unmarshal([]byte(content), &config); err != nil {
return nil, err
}
// ...
}3. Error trigger flowHere’s how the error happens step by step:
4. Why the test still passesEven though an error is logged, the test passes successfully for several reasons:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3054 +/- ##
========================================
Coverage 39.64% 39.65%
========================================
Files 457 457
Lines 39075 39133 +58
========================================
+ Hits 15493 15517 +24
- Misses 22318 22346 +28
- Partials 1264 1270 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the protocol registry package from using the legacy config package to the newer global package for configuration management, while maintaining backward compatibility with existing code. The changes enable configurations to be passed via URL attributes instead of relying on global singleton config state.
Key Changes:
- Replaced
configpackage imports withglobalpackage for configuration structures - Modified protocol initialization to accept and use URL-embedded configuration attributes
- Updated test fixtures to provide configurations via URL attributes rather than global state
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| registry/protocol/protocol_test.go | Removed global config initialization; updated test helpers to pass configurations via URL attributes |
| registry/protocol/protocol.go | Added fallback logic to use global config from URLs with backward compatibility to config package |
| go.mod | Moved github.com/spf13/viper from indirect to direct dependency |
| common/constant/key.go | Added RpcServiceInterfaceName constant |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…nate test YAML errors
|
| if rpcService == nil { | ||
| s := "reExport can not get RPCService" | ||
| return perrors.New(s) | ||
| providerConfig := config.GetProviderConfig() |
There was a problem hiding this comment.
| providerConfig := config.GetProviderConfig() | |
| //TODO: Temporary compatibility with old APIs, can be removed later | |
| providerConfig := config.GetProviderConfig() |
| return | ||
| } | ||
|
|
||
| if shutdownConfRaw, ok := exporter.registerUrl.GetAttribute(constant.ShutdownConfigPrefix); ok { |
There was a problem hiding this comment.
need to make sure is ShutdownConfig already set into url or not
There was a problem hiding this comment.
if _, ok := registryUrl.GetAttribute(constant.ShutdownConfigPrefix); !ok {
// Only set default global config when config package doesn't have one
if config.GetShutDown() == nil {
registryUrl.SetAttribute(constant.ShutdownConfigPrefix, global.DefaultShutdownConfig())
}
}
``` In the front , it has judgement.
|
why closed |
|
I will move the change to the fork of KamToHung |



@#2741
Replace config with global while ensuring compatibility in protocol.go
protocol_test.go still have some problems about TestExportWithApplicationConfig and TestGetProviderUrlWithHideKey