Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: copy bare configurations from config to global #2413

Merged
merged 11 commits into from
Sep 2, 2023

Conversation

DMwangnima
Copy link
Contributor

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:

// global conception
// configure global configurations and common modules
ins, err := dubbo.NewInstance(
	dubbo.WithApplication(
		global.WithApplication_Name("dubbo_test"),
	),
	dubbo.WithRegistry("nacos",
		global.WithRegistry_Address("127.0.0.1:8848"),
	),
	dubbo.WithMetric(
		global.WithMetric_Enable(true),
	),
)
if err != nil {
	panic(err)
}
// configure the params that only client layer cares
cli, err := ins.NewClient(
	client.WithRetries(3),
)
if err != nil {
	panic(err)
}
// then use this cli with code generated by protoc-gen-triple

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).

@sonarcloud
Copy link

sonarcloud bot commented Sep 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Contributor

@chickenlj chickenlj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@chickenlj chickenlj merged commit 38e57c7 into apache:feature-triple Sep 2, 2023
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants