From ad995d83fb12d1f87c4ccc49fa19afa1dd1b8910 Mon Sep 17 00:00:00 2001
From: "vito.he" <hxmhlt@163.com>
Date: Mon, 20 Apr 2020 14:06:17 +0800
Subject: [PATCH] Add:add for resolve rw

---
 config/service_config.go                          |  5 +++--
 metadata/identifier/metadata_identifier.go        |  4 ++--
 .../identifier/service_metadata_identifier.go     |  4 ++--
 .../identifier/subscribe_metadata_identifier.go   |  4 ++--
 .../dynamic/service_name_mapping.go               |  4 ++--
 .../dynamic/service_name_mapping_test.go          |  0
 .../memory/service_name_mapping.go                |  0
 .../service_name_mapping.go                       |  2 +-
 .../exporter/configurable/exporter_test.go        |  1 -
 metadata/service/inmemory/service_test.go         | 15 +++++++++------
 10 files changed, 21 insertions(+), 18 deletions(-)
 rename metadata/{namemapping => mapping}/dynamic/service_name_mapping.go (97%)
 rename metadata/{namemapping => mapping}/dynamic/service_name_mapping_test.go (100%)
 rename metadata/{namemapping => mapping}/memory/service_name_mapping.go (100%)
 rename metadata/{namemapping => mapping}/service_name_mapping.go (98%)

diff --git a/config/service_config.go b/config/service_config.go
index 258de856e..9bc86d600 100644
--- a/config/service_config.go
+++ b/config/service_config.go
@@ -75,10 +75,11 @@ type ServiceConfig struct {
 	unexported    *atomic.Bool
 	exported      *atomic.Bool
 	rpcService    common.RPCService
-	cacheProtocol protocol.Protocol
 	cacheMutex    sync.Mutex
-	exporters     []protocol.Exporter
+	cacheProtocol protocol.Protocol
+
 	exportersLock sync.Mutex
+	exporters     []protocol.Exporter
 }
 
 // Prefix ...
diff --git a/metadata/identifier/metadata_identifier.go b/metadata/identifier/metadata_identifier.go
index f8591b713..18b330ae0 100644
--- a/metadata/identifier/metadata_identifier.go
+++ b/metadata/identifier/metadata_identifier.go
@@ -23,12 +23,12 @@ type MetadataIdentifier struct {
 	BaseMetadataIdentifier
 }
 
-// getIdentifierKey will return string format as service:Version:Group:Side:Application
+// GetIdentifierKey will return string format as service:Version:Group:Side:Application
 func (mdi *MetadataIdentifier) GetIdentifierKey() string {
 	return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.Application)
 }
 
-// getFilePathKey will return string format as metadata/path/Version/Group/Side/Application
+// GetFilePathKey will return string format as metadata/path/Version/Group/Side/Application
 func (mdi *MetadataIdentifier) GetFilePathKey() string {
 	return mdi.BaseMetadataIdentifier.getFilePathKey(mdi.Application)
 }
diff --git a/metadata/identifier/service_metadata_identifier.go b/metadata/identifier/service_metadata_identifier.go
index c29b1e2f3..92c15704d 100644
--- a/metadata/identifier/service_metadata_identifier.go
+++ b/metadata/identifier/service_metadata_identifier.go
@@ -28,12 +28,12 @@ type ServiceMetadataIdentifier struct {
 	BaseMetadataIdentifier
 }
 
-// getIdentifierKey will return string format as service:Version:Group:Side:Protocol:"revision"+Revision
+// GetIdentifierKey will return string format as service:Version:Group:Side:Protocol:"revision"+Revision
 func (mdi *ServiceMetadataIdentifier) GetIdentifierKey() string {
 	return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.Protocol, constant.KEY_REVISON_PREFIX+mdi.Revision)
 }
 
-// getFilePathKey will return string format as metadata/path/Version/Group/Side/Protocol/"revision"+Revision
+// GetFilePathKey will return string format as metadata/path/Version/Group/Side/Protocol/"revision"+Revision
 func (mdi *ServiceMetadataIdentifier) GetFilePathKey() string {
 	return mdi.BaseMetadataIdentifier.getFilePathKey(mdi.Protocol, constant.KEY_REVISON_PREFIX+mdi.Revision)
 }
diff --git a/metadata/identifier/subscribe_metadata_identifier.go b/metadata/identifier/subscribe_metadata_identifier.go
index f50703255..e599fc9e0 100644
--- a/metadata/identifier/subscribe_metadata_identifier.go
+++ b/metadata/identifier/subscribe_metadata_identifier.go
@@ -23,12 +23,12 @@ type SubscriberMetadataIdentifier struct {
 	BaseMetadataIdentifier
 }
 
-// getIdentifierKey will return string format as service:Version:Group:Side:Revision
+// GetIdentifierKey will return string format as service:Version:Group:Side:Revision
 func (mdi *SubscriberMetadataIdentifier) GetIdentifierKey() string {
 	return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.Revision)
 }
 
-// getFilePathKey will return string format as metadata/path/Version/Group/Side/Revision
+// GetFilePathKey will return string format as metadata/path/Version/Group/Side/Revision
 func (mdi *SubscriberMetadataIdentifier) GetFilePathKey() string {
 	return mdi.BaseMetadataIdentifier.getFilePathKey(mdi.Revision)
 }
diff --git a/metadata/namemapping/dynamic/service_name_mapping.go b/metadata/mapping/dynamic/service_name_mapping.go
similarity index 97%
rename from metadata/namemapping/dynamic/service_name_mapping.go
rename to metadata/mapping/dynamic/service_name_mapping.go
index 85e94a89c..4cfac8f82 100644
--- a/metadata/namemapping/dynamic/service_name_mapping.go
+++ b/metadata/mapping/dynamic/service_name_mapping.go
@@ -31,7 +31,7 @@ import (
 	"github.com/apache/dubbo-go/common/constant"
 	"github.com/apache/dubbo-go/config"
 	"github.com/apache/dubbo-go/config_center"
-	"github.com/apache/dubbo-go/metadata/namemapping"
+	"github.com/apache/dubbo-go/metadata/mapping"
 )
 
 const (
@@ -77,6 +77,6 @@ func (d *DynamicConfigurationServiceNameMapping) buildGroup(serviceInterface str
 }
 
 // NewServiceNameMapping will create an instance of DynamicConfigurationServiceNameMapping
-func NewServiceNameMapping(dc config_center.DynamicConfiguration) namemapping.ServiceNameMapping {
+func NewServiceNameMapping(dc config_center.DynamicConfiguration) mapping.ServiceNameMapping {
 	return &DynamicConfigurationServiceNameMapping{dc: dc}
 }
diff --git a/metadata/namemapping/dynamic/service_name_mapping_test.go b/metadata/mapping/dynamic/service_name_mapping_test.go
similarity index 100%
rename from metadata/namemapping/dynamic/service_name_mapping_test.go
rename to metadata/mapping/dynamic/service_name_mapping_test.go
diff --git a/metadata/namemapping/memory/service_name_mapping.go b/metadata/mapping/memory/service_name_mapping.go
similarity index 100%
rename from metadata/namemapping/memory/service_name_mapping.go
rename to metadata/mapping/memory/service_name_mapping.go
diff --git a/metadata/namemapping/service_name_mapping.go b/metadata/mapping/service_name_mapping.go
similarity index 98%
rename from metadata/namemapping/service_name_mapping.go
rename to metadata/mapping/service_name_mapping.go
index 451a60d2c..6caed9f0b 100644
--- a/metadata/namemapping/service_name_mapping.go
+++ b/metadata/mapping/service_name_mapping.go
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package namemapping
+package mapping
 
 import (
 	gxset "github.com/dubbogo/gost/container/set"
diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go
index f563f2df3..220ef71da 100644
--- a/metadata/service/exporter/configurable/exporter_test.go
+++ b/metadata/service/exporter/configurable/exporter_test.go
@@ -114,5 +114,4 @@ func mockInitProviderWithSingleRegistry() {
 	}
 	providerConfig.Services["MockService"].InitExported()
 	config.SetProviderConfig(*providerConfig)
-
 }
diff --git a/metadata/service/inmemory/service_test.go b/metadata/service/inmemory/service_test.go
index d68990b3f..7d701cd6b 100644
--- a/metadata/service/inmemory/service_test.go
+++ b/metadata/service/inmemory/service_test.go
@@ -63,11 +63,12 @@ func TestMetadataService(t *testing.T) {
 	version := "0.0.1"
 	protocol := "dubbo"
 	beanName := "UserProvider"
-	u, _ := common.NewURL(fmt.Sprintf("%v://127.0.0.1:20000/com.ikurento.user.UserProvider?anyhost=true&"+
-		"application=BDTService&category=providers&default.timeout=10000&dubbo=dubbo-provider-golang-1.0.0&"+
-		"environment=dev&interface=%v&ip=192.168.56.1&methods=GetUser&"+
-		"module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&"+
-		"side=provider&timeout=3000&timestamp=1556509797245&group=%v&version=%v&bean.name=%v", protocol, serviceName, group, version, beanName))
+	u, _ := common.NewURL(fmt.Sprintf(`%v://127.0.0.1:20000/com.ikurento.user.UserProvider?
+			anyhost=true&application=BDTService&category=providers&default.timeout=10000&
+			dubbo=dubbo-provider-golang-1.0.0&environment=dev&interface=%v&ip=192.168.56.1&
+			methods=GetUser&module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&
+			revision=0.0.1&side=provider&timeout=3000&timestamp=1556509797245&group=%v&
+			version=%v&bean.name=%v`, protocol, serviceName, group, version, beanName))
 	mts.ExportURL(u)
 	sets, _ := mts.GetExportedURLs(serviceName, group, version, protocol)
 	assert.Equal(t, 1, sets.Size())
@@ -88,7 +89,9 @@ func TestMetadataService(t *testing.T) {
 	userProvider := &UserProvider{}
 	common.ServiceMap.Register(serviceName, protocol, userProvider)
 	mts.PublishServiceDefinition(u)
-	expected := `{"CanonicalName":"com.ikurento.user.UserProvider","CodeSource":"","Methods":[{"Name":"GetUser","ParameterTypes":["slice"],"ReturnType":"ptr","Parameters":null}],"Types":null}`
+	expected := `{"CanonicalName":"com.ikurento.user.UserProvider","CodeSource":"",
+				"Methods":[{"Name":"GetUser","ParameterTypes":["slice"],
+				"ReturnType":"ptr","Parameters":null}],"Types":null}`
 	def1, _ := mts.GetServiceDefinition(serviceName, group, version)
 	assert.Equal(t, def1, expected)
 	serviceKey := definition.ServiceDescriperBuild(serviceName, group, version)
-- 
GitLab