You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2020/01/11 05:18:02 UTC

[dubbo-go] branch develop updated: When protocol config don't have right config, remind user to check warning.

This is an automated email from the ASF dual-hosted git repository.

alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/develop by this push:
     new d01b5ee  When protocol config don't have right config, remind user to check warning.
     new a109609  Merge pull request #314 from Patrick0308/add_protocol_warning
d01b5ee is described below

commit d01b5ee8ac96fb6d0303a2fe9920d7634fb09a0a
Author: Patrick <dr...@foxmail.com>
AuthorDate: Fri Jan 10 10:06:53 2020 +0800

    When protocol config don't have right config, remind user to check warning.
---
 config/service_config.go      |  8 ++++++--
 config/service_config_test.go | 24 ++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/config/service_config.go b/config/service_config.go
index c178463..a2ed139 100644
--- a/config/service_config.go
+++ b/config/service_config.go
@@ -117,8 +117,12 @@ func (srvconfig *ServiceConfig) Export() error {
 
 	regUrls := loadRegistries(srvconfig.Registry, providerConfig.Registries, common.PROVIDER)
 	urlMap := srvconfig.getUrlMap()
-
-	for _, proto := range loadProtocol(srvconfig.Protocol, providerConfig.Protocols) {
+	protocolConfigs := loadProtocol(srvconfig.Protocol, providerConfig.Protocols)
+	if len(protocolConfigs) == 0 {
+		logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs ", srvconfig.InterfaceName, srvconfig.Protocol)
+		return nil
+	}
+	for _, proto := range protocolConfigs {
 		// registry the service reflect
 		methods, err := common.ServiceMap.Register(proto.Name, srvconfig.rpcService)
 		if err != nil {
diff --git a/config/service_config_test.go b/config/service_config_test.go
index 8ae6753..6f32308 100644
--- a/config/service_config_test.go
+++ b/config/service_config_test.go
@@ -93,6 +93,30 @@ func doInitProvider() {
 					},
 				},
 			},
+			"MockServiceNoRightProtocol": {
+				InterfaceName: "com.MockService",
+				Protocol:      "mock1",
+				Registry:      "shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2",
+				Cluster:       "failover",
+				Loadbalance:   "random",
+				Retries:       "3",
+				Group:         "huadong_idc",
+				Version:       "1.0.0",
+				Methods: []*MethodConfig{
+					{
+						Name:        "GetUser",
+						Retries:     "2",
+						Loadbalance: "random",
+						Weight:      200,
+					},
+					{
+						Name:        "GetUser1",
+						Retries:     "2",
+						Loadbalance: "random",
+						Weight:      200,
+					},
+				},
+			},
 		},
 		Protocols: map[string]*ProtocolConfig{
 			"mock": {