-
Notifications
You must be signed in to change notification settings - Fork 929
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(config): add root config api builder #1491
Conversation
config/application_config.go
Outdated
@@ -113,3 +113,49 @@ func WithMetadataType(metadataType string) ApplicationConfigOpt { | |||
ac.MetadataType = metadataType | |||
} | |||
} | |||
|
|||
type ApplicationConfigBuilder struct { | |||
*ApplicationConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config *ApplicationConfig
Codecov Report
@@ Coverage Diff @@
## config-api #1491 +/- ##
==============================================
- Coverage 42.71% 42.17% -0.55%
==============================================
Files 261 261
Lines 14957 15113 +156
==============================================
- Hits 6389 6374 -15
- Misses 7819 7994 +175
+ Partials 749 745 -4
Continue to review full report at Codecov.
|
config/application_config.go
Outdated
application *ApplicationConfig | ||
} | ||
|
||
func (acb *ApplicationConfigBuilder) Organization(organization string) *ApplicationConfigBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
赋值函数为啥不在前面加上 Set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一般这种builder模式的运用,在链式赋值时都不会使用set。
我理解是因为这种模式下没有 get 的场景,所以单独的 set 并不会给到更多的语义信息,可忽略。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可参考 curator,okhttp3 等框架。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉写成了 java。。。。。。。。。。。go 不是用以下形式吗?
&ApplicationConfigBuilder{
key1:value1,
key2:value2,
}
config/root_config.go
Outdated
rootConfig *RootConfig | ||
} | ||
|
||
func (rb *RootConfigBuilder) Application(application *ApplicationConfig) *RootConfigBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加上 Set 前缀
config/application_config.go
Outdated
application *ApplicationConfig | ||
} | ||
|
||
func (acb *ApplicationConfigBuilder) Organization(organization string) *ApplicationConfigBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉写成了 java。。。。。。。。。。。go 不是用以下形式吗?
&ApplicationConfigBuilder{
key1:value1,
key2:value2,
}
@@ -188,19 +188,19 @@ func RPCService(service common.RPCService) { | |||
// So you don't need to worry about the race condition | |||
func GetMetricConfig() *MetricConfig { | |||
// todo | |||
//if GetBaseConfig().MetricConfig == nil { | |||
//if GetBaseConfig().Metric == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo 要不干掉?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
解释一下上面的问题,
&ApplicationConfigBuilder{
key1:value1,
key2:value2,
}
是一种初始化方式,这个builder是另一个问题,是前段时间讨论后针对目前with的config api一个替换做法,我个人理解builder不算是java专有的吧,这个模式go里面也有用,但是java比较普遍,我们也是讨论了觉得这种方式可读性比with更强所以借鉴这种写法。
return &ProtocolConfigBuilder{protocolConfig: &ProtocolConfig{}} | ||
} | ||
|
||
type ProtocolConfigBuilder struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里也是。。。感觉写成了 java
@@ -284,3 +272,98 @@ func WithRegistryParams(params map[string]string) RegistryConfigOpt { | |||
return config | |||
} | |||
} | |||
|
|||
func NewRegistryConfigBuilder() *RegistryConfigBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里也是 java
return &RootConfigBuilder{rootConfig: &RootConfig{}} | ||
} | ||
|
||
type RootConfigBuilder struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里也是 java
return nil | ||
} | ||
|
||
func NewServiceDiscoveryConfigBuilder() *ServiceDiscoveryConfigBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里也 java
hi,boy。关于dubboBootstrap 和configLoader我有一点疑问,dubboBootstrap 顾名思义是作为程序的引导类,一般来说引导类只有一个,但是似乎configLoader也是做引导程序使用的,这两个是单独对程序进行加载和启动吗?另外假设我使用api配置和外部化配置混用应该如何使用配置? @Mulavar |
目前暂不考虑混用的场景,bootstrap 这块和 loader 的关系确实不太明晰,我们正在讨论,进一步是不是要合并,还是将程序入口拆分得更加合理 @XiaoWeiKIN |
I thinks this pr is able to merge, and we would fix TODOs soon. |
What this PR does:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: