Mulavar commented on a change in pull request #1425:
URL: https://github.com/apache/dubbo-go/pull/1425#discussion_r699851006
##########
File path: remoting/getty/getty_client.go
##########
@@ -59,27 +59,30 @@ func initClient(protocol string) {
return
}
- // load clientconfig from consumer_config
+ // load client config from rootConfig.Protocols
// default use dubbo
if config.GetApplicationConfig() == nil {
return
}
- protocolConf := config.GetRootConfig().Network
+ if config.GetRootConfig().Protocols == nil {
+ return
+ }
+
+ protocolConf := config.GetRootConfig().Protocols[protocol]
defaultClientConfig := GetDefaultClientConfig()
if protocolConf == nil {
- logger.Info("protocol_conf default use dubbo config")
+ logger.Info("use default getty client config")
} else {
- //dubboConf :=
protocolConf.(map[interface{}]interface{})[protocol]
- dubboConf := protocolConf[protocol]
- if dubboConf == nil {
- logger.Warnf("dubboConf is nil")
+ gettyClientConfig := protocolConf.Params
+ if gettyClientConfig == nil {
+ logger.Warnf("gettyClientConfig is nil")
return
}
- dubboConfByte, err := yaml.Marshal(dubboConf)
+ gettyClientConfigBytes, err := yaml.Marshal(gettyClientConfig)
Review comment:
测了一下,这里反序列化的对象是defaultClientConfig,defaultClientConfig本身已经有默认值了,所以marshal后做unmarshal时,如果gettyClientConfig有些参数没设置,会直接使用defaultClientConfig已有的默认值,跟dubbo
url的结果是一致的。
##########
File path: config/protocol_config.go
##########
@@ -27,9 +27,10 @@ import (
// ProtocolConfig is protocol configuration
type ProtocolConfig struct {
- Name string `default:"dubbo" validate:"required" yaml:"name"
json:"name,omitempty" property:"name"`
- Ip string `yaml:"ip" json:"ip,omitempty" property:"ip"`
- Port string `default:"2000" yaml:"port" json:"port,omitempty"
property:"port"`
+ Name string `default:"dubbo" validate:"required" yaml:"name"
json:"name,omitempty" property:"name"`
+ Ip string `yaml:"ip" json:"ip,omitempty" property:"ip"`
+ Port string `default:"2000" yaml:"port" json:"port,omitempty"
property:"port"`
+ Params interface{} `yaml:"params" json:"params,omitempty"
property:"params"`
Review comment:
这地方我有想过用map还是interface,选interface是因为用map,value的类型用string,在后续需要作很多额外的类型强转工作,如果用interface可以直接做到默认值的方式(见下面comment的讨论),用map相对来说没有什么优势(或许可读性是优势,但考虑到如getty有专门的结构体去表示这部分参数,可读性也不差)。
--
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]