You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/09/01 09:46:47 UTC

[GitHub] [dubbo-go] zhaoyunxing92 commented on a change in pull request #1425: feat(config): add new protocol config

zhaoyunxing92 commented on a change in pull request #1425:
URL: https://github.com/apache/dubbo-go/pull/1425#discussion_r699288163



##########
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是不是会好点

##########
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:
       不建议这个地方用marshal处理,可以用dubbo url方式这样可以设置一些默认值




-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org