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 2021/09/05 04:13:55 UTC
[dubbo-go] branch config-enhance updated: Fix: metadataService port
conflict (#1441)
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch config-enhance
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/config-enhance by this push:
new a1e4548 Fix: metadataService port conflict (#1441)
a1e4548 is described below
commit a1e4548f1e68a01322e1e68126b8c29bd1e3b2a9
Author: alchemy-lee <27...@qq.com>
AuthorDate: Sun Sep 5 12:13:49 2021 +0800
Fix: metadataService port conflict (#1441)
* fix metadata bug
* fix metadata bug
* fix metadata bug
* fix service discovery bug
* fix unit test bug
---
config/reference_config.go | 15 +++++++++++++--
metadata/service/exporter/configurable/exporter.go | 5 +++--
metadata/service/exporter/configurable/exporter_test.go | 2 +-
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/config/reference_config.go b/config/reference_config.go
index 44583e6..a4142bc 100644
--- a/config/reference_config.go
+++ b/config/reference_config.go
@@ -137,7 +137,12 @@ func (rc *ReferenceConfig) Refer(_ interface{}) {
}
if len(rc.urls) == 1 {
- rc.invoker = extension.GetProtocol(rc.urls[0].Protocol).Refer(rc.urls[0])
+ if rc.urls[0].Protocol == constant.SERVICE_REGISTRY_PROTOCOL {
+ rc.invoker = extension.GetProtocol("registry").Refer(rc.urls[0])
+ } else {
+ rc.invoker = extension.GetProtocol(rc.urls[0].Protocol).Refer(rc.urls[0])
+ }
+
// c.URL != "" is direct call
if rc.URL != "" {
//filter
@@ -167,7 +172,13 @@ func (rc *ReferenceConfig) Refer(_ interface{}) {
invokers := make([]protocol.Invoker, 0, len(rc.urls))
var regURL *common.URL
for _, u := range rc.urls {
- invoker := extension.GetProtocol(u.Protocol).Refer(u)
+ var invoker protocol.Invoker
+ if u.Protocol == constant.SERVICE_REGISTRY_PROTOCOL {
+ invoker = extension.GetProtocol("registry").Refer(u)
+ } else {
+ invoker = extension.GetProtocol(u.Protocol).Refer(u)
+ }
+
// c.URL != "" is direct call
if rc.URL != "" {
//filter
diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go
index 2b35b32..50d0485 100644
--- a/metadata/service/exporter/configurable/exporter.go
+++ b/metadata/service/exporter/configurable/exporter.go
@@ -18,6 +18,7 @@
package configurable
import (
+ "strconv"
"sync"
)
@@ -64,8 +65,8 @@ func (exporter *MetadataServiceExporter) Export(url *common.URL) error {
config.WithServiceID(constant.SIMPLE_METADATA_SERVICE_NAME),
config.WithServiceProtocolKeys(constant.DEFAULT_PROTOCOL),
config.WithServiceProtocol(constant.DEFAULT_PROTOCOL, config.NewProtocolConfig(
- config.WithProtocolName(url.SubURL.Protocol),
- config.WithProtocolPort(url.SubURL.Port),
+ config.WithProtocolName(constant.DEFAULT_PROTOCOL),
+ config.WithProtocolPort(strconv.Itoa(constant.DEFAULT_METADATAPORT)),
)),
config.WithServiceRegistry("N/A"),
config.WithServiceInterface(constant.METADATA_SERVICE_NAME),
diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go
index 2bbbdd1..09f1c9d 100644
--- a/metadata/service/exporter/configurable/exporter_test.go
+++ b/metadata/service/exporter/configurable/exporter_test.go
@@ -69,7 +69,7 @@ func TestConfigurableExporter(t *testing.T) {
assert.Equal(t, false, exported.IsExported())
assert.NoError(t, exported.Export(registryURL))
assert.Equal(t, true, exported.IsExported())
- assert.Regexp(t, "dubbo://127.0.0.1:20003/org.apache.dubbo.metadata.MetadataService*", exported.GetExportedURLs()[0].String())
+ assert.Regexp(t, "dubbo://127.0.0.1:20005/org.apache.dubbo.metadata.MetadataService*", exported.GetExportedURLs()[0].String())
exported.Unexport()
assert.Equal(t, false, exported.IsExported())
})