feat: copy bare configurations from config to global #2413
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Based on #2406, we decided to move all bare configurations from config package to global package( this package name would be replaced with a more ideal one in the future). After that, the user-side code would change like this:
For user-side, users make use of global.WithXXX_XXX(eg. WithApplication_Name) to create specific configuration. Then users invoke dubbo.WithXXX or client.WithXXX to inject these configurations. By this approach, every module could rely on global package and there is no circular dependencies problem.
introducing a global package seems confusing, but we have strong reason. For compatibility, config.Load must be supported in new dubbo-go version. It means that config package as the entrance should rely on other modules. If client, server and dubbo packages make use of configurations from client package directly, there would be circular dependencies. So we have to introduce this intermediate package.
In the future, we hope that bare configurations from client package would be moved to global package and related actions and logics of configuration would be moved to related module (eg. all functions belong to config.RegistryConfig would be moved to registry package and exported as API).