From c875ae72a9410455f752d3a56f761efcd345136b Mon Sep 17 00:00:00 2001
From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com>
Date: Tue, 13 Jul 2021 13:18:22 +0800
Subject: [PATCH] fix: fix dynamic naming mapping of app level service disc
(#155)
* fix: fix dynamic mapping
* fix
---
.run/router-client (1).run.xml | 17 ++++++++++
.run/router-server (1).run.xml | 15 +++++++++
.run/router-server2 (1).run.xml | 15 +++++++++
go.mod | 2 +-
go.sum | 2 ++
.../nacos/go-client/cmd/client.go | 3 +-
.../nacos/go-client/conf/client.yml | 6 +++-
.../nacos/go-client/conf/server.yml | 33 -------------------
.../nacos/go-server/cmd/server.go | 10 +++---
.../nacos/go-server/conf/client.yml | 6 +++-
.../nacos/go-server/conf/server.yml | 5 +++
.../go-server/tests/integration/main_test.go | 3 +-
.../zookeeper/go-client/cmd/client.go | 3 +-
.../zookeeper/go-client/conf/client.yml | 6 +++-
.../zookeeper/go-server/cmd/server.go | 13 ++++----
.../zookeeper/go-server/conf/client.yml | 6 +++-
.../zookeeper/go-server/conf/server.yml | 4 +++
.../zookeeper/go-server/pkg/user.go | 5 +--
.../go-server/tests/integration/main_test.go | 3 +-
19 files changed, 100 insertions(+), 57 deletions(-)
create mode 100644 .run/router-client (1).run.xml
create mode 100644 .run/router-server (1).run.xml
create mode 100644 .run/router-server2 (1).run.xml
delete mode 100644 registry/servicediscovery/nacos/go-client/conf/server.yml
diff --git a/.run/router-client (1).run.xml b/.run/router-client (1).run.xml
new file mode 100644
index 0000000000..62a4ab9690
--- /dev/null
+++ b/.run/router-client (1).run.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.run/router-server (1).run.xml b/.run/router-server (1).run.xml
new file mode 100644
index 0000000000..fa3361ede2
--- /dev/null
+++ b/.run/router-server (1).run.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.run/router-server2 (1).run.xml b/.run/router-server2 (1).run.xml
new file mode 100644
index 0000000000..26144b20b7
--- /dev/null
+++ b/.run/router-server2 (1).run.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/go.mod b/go.mod
index d82f0c670f..1d8039f027 100644
--- a/go.mod
+++ b/go.mod
@@ -1,7 +1,7 @@
module github.com/apache/dubbo-go-samples
require (
- dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20210705181411-e43af85126fd
+ dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20210708063655-af290429dee4
github.com/alibaba/sentinel-golang v1.0.2
github.com/apache/dubbo-getty v1.4.3
github.com/apache/dubbo-go-hessian2 v1.9.2
diff --git a/go.sum b/go.sum
index c4f08dc7b7..24e41632a7 100644
--- a/go.sum
+++ b/go.sum
@@ -15,6 +15,8 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20210705181411-e43af85126fd h1:osLG5U8sKqWKyQnw4hIsQZSBKThYkRKWZ4BcCAA737A=
dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20210705181411-e43af85126fd/go.mod h1:2l+IXuSuJvEk2g/ze1la8t1sX+yJH220aHo6JJVriM8=
+dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20210708063655-af290429dee4 h1:JRGjw66CguqaOeYigLauTdccWqnvy7U3OYqAHzXYmlw=
+dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20210708063655-af290429dee4/go.mod h1:2l+IXuSuJvEk2g/ze1la8t1sX+yJH220aHo6JJVriM8=
github.com/Azure/azure-sdk-for-go v40.3.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI=
github.com/Azure/go-autorest/autorest v0.9.3/go.mod h1:GsRuLYvwzLjjjRoWEIyMUaYq8GNUx2nRB378IPt/1p0=
diff --git a/registry/servicediscovery/nacos/go-client/cmd/client.go b/registry/servicediscovery/nacos/go-client/cmd/client.go
index d3257e3942..25d2d78a59 100644
--- a/registry/servicediscovery/nacos/go-client/cmd/client.go
+++ b/registry/servicediscovery/nacos/go-client/cmd/client.go
@@ -28,8 +28,9 @@ import (
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
"dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/config_center/nacos"
_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
- _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/memory"
+ _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/dynamic"
_ "dubbo.apache.org/dubbo-go/v3/metadata/report/nacos"
_ "dubbo.apache.org/dubbo-go/v3/metadata/service/local"
_ "dubbo.apache.org/dubbo-go/v3/metadata/service/remote"
diff --git a/registry/servicediscovery/nacos/go-client/conf/client.yml b/registry/servicediscovery/nacos/go-client/conf/client.yml
index 6d539e4e0a..0f2223458a 100644
--- a/registry/servicediscovery/nacos/go-client/conf/client.yml
+++ b/registry/servicediscovery/nacos/go-client/conf/client.yml
@@ -6,6 +6,11 @@ request_timeout: "3s"
# connect timeout
connect_timeout: "3s"
+# config center config
+config_center:
+ protocol: "nacos"
+ address: "127.0.0.1:8848"
+
# application config
application:
organization: "dubbo.io"
@@ -42,7 +47,6 @@ service_discovery:
references:
"UserProvider":
registry: "demoServiceDiscovery"
- provided_by: "UserInfoServer"
protocol: "dubbo"
interface: "org.apache.dubbo.UserProvider"
cluster: "failover"
diff --git a/registry/servicediscovery/nacos/go-client/conf/server.yml b/registry/servicediscovery/nacos/go-client/conf/server.yml
deleted file mode 100644
index 8508de2d0a..0000000000
--- a/registry/servicediscovery/nacos/go-client/conf/server.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-# dubbo server yaml configure file
-
-# application config
-application:
- organization: "dubbo.io"
- name: "UserInfoServer"
- module: "dubbo-go user-info server"
- version: "0.0.1"
- environment: "dev"
-
-# registry config
-registries:
- "demoServiceDiscovery":
- protocol: "service-discovery"
- params:
- service_discovery: "nacos1"
- name_mapping: "dynamic"
- metadata: "default"
-
-remote:
- nacos:
- address: "127.0.0.1:8848"
- timeout: "5s"
-
-metadata_report:
- protocol: "nacos"
- remote_ref: "nacos"
-
-service_discovery:
- nacos1:
- protocol: "nacos"
- remote_ref: "nacos"
- group: "dubbo"
\ No newline at end of file
diff --git a/registry/servicediscovery/nacos/go-server/cmd/server.go b/registry/servicediscovery/nacos/go-server/cmd/server.go
index 77df35cfc7..cbfd905647 100644
--- a/registry/servicediscovery/nacos/go-server/cmd/server.go
+++ b/registry/servicediscovery/nacos/go-server/cmd/server.go
@@ -27,14 +27,18 @@ import (
import (
hessian "github.com/apache/dubbo-go-hessian2"
+ "github.com/apache/dubbo-go-samples/registry/servicediscovery/nacos/go-server/pkg"
+)
+import (
_ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
"dubbo.apache.org/dubbo-go/v3/common/logger"
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
"dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/config_center/nacos"
_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
- _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/memory"
+ _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/dynamic"
_ "dubbo.apache.org/dubbo-go/v3/metadata/report/nacos"
_ "dubbo.apache.org/dubbo-go/v3/metadata/service/remote"
_ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
@@ -44,10 +48,6 @@ import (
_ "dubbo.apache.org/dubbo-go/v3/registry/servicediscovery"
)
-import (
- "github.com/apache/dubbo-go-samples/registry/servicediscovery/nacos/go-server/pkg"
-)
-
var (
survivalTimeout = int(3e9)
)
diff --git a/registry/servicediscovery/nacos/go-server/conf/client.yml b/registry/servicediscovery/nacos/go-server/conf/client.yml
index 6d539e4e0a..0f2223458a 100644
--- a/registry/servicediscovery/nacos/go-server/conf/client.yml
+++ b/registry/servicediscovery/nacos/go-server/conf/client.yml
@@ -6,6 +6,11 @@ request_timeout: "3s"
# connect timeout
connect_timeout: "3s"
+# config center config
+config_center:
+ protocol: "nacos"
+ address: "127.0.0.1:8848"
+
# application config
application:
organization: "dubbo.io"
@@ -42,7 +47,6 @@ service_discovery:
references:
"UserProvider":
registry: "demoServiceDiscovery"
- provided_by: "UserInfoServer"
protocol: "dubbo"
interface: "org.apache.dubbo.UserProvider"
cluster: "failover"
diff --git a/registry/servicediscovery/nacos/go-server/conf/server.yml b/registry/servicediscovery/nacos/go-server/conf/server.yml
index be4b5af70d..205e936331 100644
--- a/registry/servicediscovery/nacos/go-server/conf/server.yml
+++ b/registry/servicediscovery/nacos/go-server/conf/server.yml
@@ -1,5 +1,10 @@
# dubbo server yaml configure file
+# config center config
+config_center:
+ protocol: "nacos"
+ address: "127.0.0.1:8848"
+
# application config
application:
organization: "dubbo.io"
diff --git a/registry/servicediscovery/nacos/go-server/tests/integration/main_test.go b/registry/servicediscovery/nacos/go-server/tests/integration/main_test.go
index e3686bf32e..79699c6180 100644
--- a/registry/servicediscovery/nacos/go-server/tests/integration/main_test.go
+++ b/registry/servicediscovery/nacos/go-server/tests/integration/main_test.go
@@ -24,8 +24,9 @@ import (
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
"dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/config_center/nacos"
_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
- _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/memory"
+ _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/dynamic"
_ "dubbo.apache.org/dubbo-go/v3/metadata/report/nacos"
_ "dubbo.apache.org/dubbo-go/v3/metadata/service/local"
_ "dubbo.apache.org/dubbo-go/v3/metadata/service/remote"
diff --git a/registry/servicediscovery/zookeeper/go-client/cmd/client.go b/registry/servicediscovery/zookeeper/go-client/cmd/client.go
index 36a2532c45..e235246344 100644
--- a/registry/servicediscovery/zookeeper/go-client/cmd/client.go
+++ b/registry/servicediscovery/zookeeper/go-client/cmd/client.go
@@ -27,8 +27,9 @@ import (
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
"dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/config_center/zookeeper"
_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
- _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/memory"
+ _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/dynamic"
_ "dubbo.apache.org/dubbo-go/v3/metadata/report/zookeeper"
_ "dubbo.apache.org/dubbo-go/v3/metadata/service/local"
_ "dubbo.apache.org/dubbo-go/v3/metadata/service/remote"
diff --git a/registry/servicediscovery/zookeeper/go-client/conf/client.yml b/registry/servicediscovery/zookeeper/go-client/conf/client.yml
index a31b91942b..4911ee761d 100644
--- a/registry/servicediscovery/zookeeper/go-client/conf/client.yml
+++ b/registry/servicediscovery/zookeeper/go-client/conf/client.yml
@@ -6,6 +6,11 @@ request_timeout: "3s"
# connect timeout
connect_timeout: "3s"
+# config center config
+config_center:
+ protocol: "zookeeper"
+ address: "127.0.0.1:2181"
+
# application config
application:
organization: "dubbo.io"
@@ -41,7 +46,6 @@ service_discovery:
references:
"UserProvider":
registry: "demoServiceDiscovery"
- provided_by: "UserInfoServer"
protocol: "dubbo"
interface: "org.apache.dubbo.UserProvider"
cluster: "failover"
diff --git a/registry/servicediscovery/zookeeper/go-server/cmd/server.go b/registry/servicediscovery/zookeeper/go-server/cmd/server.go
index be0a9344cf..3ec4efa2b3 100644
--- a/registry/servicediscovery/zookeeper/go-server/cmd/server.go
+++ b/registry/servicediscovery/zookeeper/go-server/cmd/server.go
@@ -25,19 +25,15 @@ import (
"time"
)
-import (
- hessian "github.com/apache/dubbo-go-hessian2"
- "github.com/apache/dubbo-go-samples/registry/servicediscovery/zookeeper/go-server/pkg"
-)
-
import (
_ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
"dubbo.apache.org/dubbo-go/v3/common/logger"
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
"dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/config_center/zookeeper"
_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
- _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/memory"
+ _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/dynamic"
_ "dubbo.apache.org/dubbo-go/v3/metadata/report/zookeeper"
_ "dubbo.apache.org/dubbo-go/v3/metadata/service/remote"
_ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
@@ -45,6 +41,11 @@ import (
_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
_ "dubbo.apache.org/dubbo-go/v3/registry/servicediscovery"
_ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
+ hessian "github.com/apache/dubbo-go-hessian2"
+)
+
+import (
+ "github.com/apache/dubbo-go-samples/registry/servicediscovery/zookeeper/go-server/pkg"
)
var (
diff --git a/registry/servicediscovery/zookeeper/go-server/conf/client.yml b/registry/servicediscovery/zookeeper/go-server/conf/client.yml
index a31b91942b..4911ee761d 100644
--- a/registry/servicediscovery/zookeeper/go-server/conf/client.yml
+++ b/registry/servicediscovery/zookeeper/go-server/conf/client.yml
@@ -6,6 +6,11 @@ request_timeout: "3s"
# connect timeout
connect_timeout: "3s"
+# config center config
+config_center:
+ protocol: "zookeeper"
+ address: "127.0.0.1:2181"
+
# application config
application:
organization: "dubbo.io"
@@ -41,7 +46,6 @@ service_discovery:
references:
"UserProvider":
registry: "demoServiceDiscovery"
- provided_by: "UserInfoServer"
protocol: "dubbo"
interface: "org.apache.dubbo.UserProvider"
cluster: "failover"
diff --git a/registry/servicediscovery/zookeeper/go-server/conf/server.yml b/registry/servicediscovery/zookeeper/go-server/conf/server.yml
index f67a3867d5..4f79f23572 100644
--- a/registry/servicediscovery/zookeeper/go-server/conf/server.yml
+++ b/registry/servicediscovery/zookeeper/go-server/conf/server.yml
@@ -1,4 +1,8 @@
# dubbo server yaml configure file
+# config center config
+config_center:
+ protocol: "zookeeper"
+ address: "127.0.0.1:2181"
# application config
application:
diff --git a/registry/servicediscovery/zookeeper/go-server/pkg/user.go b/registry/servicediscovery/zookeeper/go-server/pkg/user.go
index 5689d5c5d8..8612b9de70 100644
--- a/registry/servicediscovery/zookeeper/go-server/pkg/user.go
+++ b/registry/servicediscovery/zookeeper/go-server/pkg/user.go
@@ -22,13 +22,10 @@ import (
"time"
)
-import (
- "github.com/dubbogo/gost/log"
-)
-
import (
"dubbo.apache.org/dubbo-go/v3/config"
hessian "github.com/apache/dubbo-go-hessian2"
+ "github.com/dubbogo/gost/log"
)
func init() {
diff --git a/registry/servicediscovery/zookeeper/go-server/tests/integration/main_test.go b/registry/servicediscovery/zookeeper/go-server/tests/integration/main_test.go
index 4be15ccf74..c2abf29cc9 100644
--- a/registry/servicediscovery/zookeeper/go-server/tests/integration/main_test.go
+++ b/registry/servicediscovery/zookeeper/go-server/tests/integration/main_test.go
@@ -35,8 +35,9 @@ import (
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
"dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/config_center/zookeeper"
_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
- _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/memory"
+ _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/dynamic"
_ "dubbo.apache.org/dubbo-go/v3/metadata/report/zookeeper"
_ "dubbo.apache.org/dubbo-go/v3/metadata/service/local"
_ "dubbo.apache.org/dubbo-go/v3/metadata/service/remote"