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/10/26 05:14:35 UTC
[dubbo-go-samples] branch master updated: add mesh route sample
(#280)
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
The following commit(s) were added to refs/heads/master by this push:
new 1c3636e add mesh route sample (#280)
1c3636e is described below
commit 1c3636ee8de6c4c4331e61db2859a2c7325db8be
Author: Mulavar <97...@qq.com>
AuthorDate: Tue Oct 26 13:14:15 2021 +0800
add mesh route sample (#280)
* add mesh route sample
* add mesh route integrate test
* fix mesh route integrate test & add .run.xml
* add imports
* fix int32 assert error
* format yml
Co-authored-by: dongjianhui03 <do...@meituan.com>
---
.run/route/meshroute/meshroute-go-client.run.xml | 14 +++
.run/route/meshroute/meshroute-go-server.run.xml | 14 +++
go.mod | 2 +-
go.sum | 12 ++-
.../tests/integration/greetprovider_test.go | 94 +++++++++++++++++++
.../route/meshroute/tests/integration/main_test.go | 48 ++++++++++
route/meshroute/README.md | 9 ++
route/meshroute/README_zh.md | 9 ++
route/meshroute/go-client/cmd/client.go | 101 +++++++++++++++++++++
route/meshroute/go-client/conf/dubbogo.yml | 17 ++++
route/meshroute/go-client/conf/mesh_route.yml | 39 ++++++++
route/meshroute/go-server/cmd/server.go | 50 ++++++++++
route/meshroute/go-server/conf/dubbogo.yml | 23 +++++
start_integrate_test.sh | 6 +-
tracing/README.md | 2 +-
15 files changed, 434 insertions(+), 6 deletions(-)
diff --git a/.run/route/meshroute/meshroute-go-client.run.xml b/.run/route/meshroute/meshroute-go-client.run.xml
new file mode 100644
index 0000000..a3d60cf
--- /dev/null
+++ b/.run/route/meshroute/meshroute-go-client.run.xml
@@ -0,0 +1,14 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="meshroute-go-client" type="GoApplicationRunConfiguration" factoryName="Go Application">
+ <module name="dubbo-go-samples" />
+ <working_directory value="$PROJECT_DIR$" />
+ <envs>
+ <env name="DUBBO_GO_CONFIG_PATH" value="$PROJECT_DIR$/route/meshroute/go-client/conf/dubbogo.yml" />
+ </envs>
+ <kind value="PACKAGE" />
+ <package value="github.com/apache/dubbo-go-samples/route/meshroute/go-client/cmd" />
+ <directory value="$PROJECT_DIR$/../dubbo-go" />
+ <filePath value="$PROJECT_DIR$/route/meshroute/go-client/cmd/client.go" />
+ <method v="2" />
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/.run/route/meshroute/meshroute-go-server.run.xml b/.run/route/meshroute/meshroute-go-server.run.xml
new file mode 100644
index 0000000..c82db72
--- /dev/null
+++ b/.run/route/meshroute/meshroute-go-server.run.xml
@@ -0,0 +1,14 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="meshroute-go-server" type="GoApplicationRunConfiguration" factoryName="Go Application">
+ <module name="dubbo-go-samples" />
+ <working_directory value="$PROJECT_DIR$" />
+ <envs>
+ <env name="DUBBO_GO_CONFIG_PATH" value="$PROJECT_DIR$/route/meshroute/go-server/conf/dubbogo.yml" />
+ </envs>
+ <kind value="PACKAGE" />
+ <package value="github.com/apache/dubbo-go-samples/route/meshroute/go-server/cmd" />
+ <directory value="$PROJECT_DIR$/../dubbo-go" />
+ <filePath value="$PROJECT_DIR$/route/meshroute/go-server/cmd/server.go" />
+ <method v="2" />
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/go.mod b/go.mod
index 2f989ac..bc80906 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.20211025055545-a15f72aa4fa8
+ dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20211025072335-e5519450e07f
github.com/apache/dubbo-go-hessian2 v1.9.4-0.20210917102639-74a8ece5f3cb
github.com/dubbogo/gost v1.11.18
github.com/dubbogo/net v0.0.4
diff --git a/go.sum b/go.sum
index 7a7da9f..1a1dc39 100644
--- a/go.sum
+++ b/go.sum
@@ -33,8 +33,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
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.20211025055545-a15f72aa4fa8 h1:8yr3rIpMiuTXm61JAWwoBdSJSnx2n4NhUAmEebcVQN4=
-dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20211025055545-a15f72aa4fa8/go.mod h1:CNgt1+bui3uWepjoOOi4PVsuf6ZDQZLu0V8sWY02jT0=
+dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20211025072335-e5519450e07f h1:BABYh/iddWO9oCcq+NaOoRIiLdU1GMxlRkS8/3Wx8RI=
+dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20211025072335-e5519450e07f/go.mod h1:CNgt1+bui3uWepjoOOi4PVsuf6ZDQZLu0V8sWY02jT0=
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI=
github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0=
@@ -290,6 +290,7 @@ github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4er
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
@@ -416,6 +417,7 @@ github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/hashicorp/golang-lru v0.5.3 h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8Bppgk=
github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
@@ -928,6 +930,7 @@ golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4Iltr
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c h1:pkQiBZBvdos9qq4wBAHqlzuZHEXo07pqV06ef90u1WI=
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -1008,6 +1011,7 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069 h1:siQdpVirKtzPhKl3lZWozZraCFObP8S1v6PRp0bLrtU=
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -1112,6 +1116,7 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
+google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
@@ -1239,9 +1244,11 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
+k8s.io/api v0.16.9 h1:3vCx0WX9qcg1Hv4aQ/G1tiIKectGVuimvPVTJU4VOCA=
k8s.io/api v0.16.9/go.mod h1:Y7dZNHs1Xy0mSwSlzL9QShi6qkljnN41yR8oWCRTDe8=
k8s.io/apimachinery v0.16.9 h1:ESUZ4hMBUKF2kn2HBFL5zM/wQv4j/0uRbR7AjgqGJ4o=
k8s.io/apimachinery v0.16.9/go.mod h1:Xk2vD2TRRpuWYLQNM6lT9R7DSFZUYG03SarNkbGrnKE=
+k8s.io/client-go v0.16.9 h1:6Eh4lMDxFtDzBkqid1AOL3bQ/pPYrulx8l23DXw4mRU=
k8s.io/client-go v0.16.9/go.mod h1:ThjPlh7Kx+XoBFOCt775vx5J7atwY7F/zaFzTco5gL0=
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
@@ -1249,6 +1256,7 @@ k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E=
+k8s.io/utils v0.0.0-20190801114015-581e00157fb1 h1:+ySTxfHnfzZb9ys375PXNlLhkJPLKgHajBU0N62BDvE=
k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
diff --git a/integrate_test/route/meshroute/tests/integration/greetprovider_test.go b/integrate_test/route/meshroute/tests/integration/greetprovider_test.go
new file mode 100644
index 0000000..7ae1671
--- /dev/null
+++ b/integrate_test/route/meshroute/tests/integration/greetprovider_test.go
@@ -0,0 +1,94 @@
+// +build integration
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package integration
+
+import (
+ "context"
+ "testing"
+)
+
+import (
+ _ "dubbo.apache.org/dubbo-go/v3/common/logger"
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+
+ "github.com/stretchr/testify/assert"
+)
+
+import (
+ api "github.com/apache/dubbo-go-samples/api"
+)
+
+const MeshRouteConf = "apiVersion: service.dubbo.apache.org/v1alpha1\n" +
+ "kind: DestinationRule\n" +
+ "metadata: { name: demo-route }\n" +
+ "spec:\n" +
+ " host: demo\n" +
+ " subsets:\n" +
+ " - labels: { env-sign: xxx, tag1: hello }\n" +
+ " name: isolation\n" +
+ " - labels: { env-sign: yyy }\n" +
+ " name: testing-trunk\n" +
+ " - labels: { env-sign: zzz }\n" +
+ " name: testing\n" +
+ " trafficPolicy:\n" +
+ " loadBalancer: { simple: ROUND_ROBIN }\n\n" +
+ "---\n\n" +
+ "apiVersion: service.dubbo.apache.org/v1alpha1\n" +
+ "kind: VirtualService\n" +
+ "metadata: {name: demo-route}\n" +
+ "spec:\n" +
+ " dubbo:\n" +
+ " - routedetail:\n" +
+ " - match:\n" +
+ " - sourceLabels: {trafficLabel: xxx}\n" +
+ " name: xxx-project\n" +
+ " route:\n" +
+ " - destination: {host: demo, subset: isolation}\n" +
+ " - match:\n" +
+ " - sourceLabels: {trafficLabel: testing-trunk}\n" +
+ " name: testing-trunk\n" +
+ " route:\n" +
+ " - destination: {host: demo, subset: testing-trunk}\n" +
+ " - name: testing\n" +
+ " route:\n" +
+ " - destination: {host: demo, subset: testing}\n" +
+ " services:\n" +
+ " - {exact: com.apache.dubbo.sample.basic.IGreeter}\n" +
+ " hosts: [demo]"
+
+func TestGetUser(t *testing.T) {
+ config.GetRootConfig().ConfigCenter = config.NewConfigCenterConfigBuilder().SetProtocol("zookeeper").SetAddress("127.0.0.1:2181").SetDataID("dubbo-go-samples-configcenter-zookeeper-client").Build()
+ dynamicConfiguration, err := config.GetRootConfig().ConfigCenter.GetDynamicConfiguration()
+ assert.Nil(t, err)
+ // 1. publish mesh route config
+ err = dynamicConfiguration.PublishConfig("dubbo.io.MESHAPPRULE", "dubbo", MeshRouteConf)
+ assert.Nil(t, err)
+
+ req := &api.HelloRequest{
+ Name: "Dong",
+ }
+ reply, err := grpcGreeterImpl.SayHello(context.Background(), req)
+ assert.Nil(t, err)
+
+ assert.Equal(t, "Hello Dong", reply.Name)
+ assert.Equal(t, "12345", reply.Id)
+ assert.Equal(t, int32(21), reply.Age)
+}
diff --git a/integrate_test/route/meshroute/tests/integration/main_test.go b/integrate_test/route/meshroute/tests/integration/main_test.go
new file mode 100644
index 0000000..cec9df6
--- /dev/null
+++ b/integrate_test/route/meshroute/tests/integration/main_test.go
@@ -0,0 +1,48 @@
+// +build integration
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package integration
+
+import (
+ "os"
+ "testing"
+ "time"
+)
+
+import (
+ _ "dubbo.apache.org/dubbo-go/v3/common/logger"
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+)
+
+import (
+ api "github.com/apache/dubbo-go-samples/api"
+)
+
+var (
+ grpcGreeterImpl = &api.GreeterClientImpl{}
+)
+
+func TestMain(m *testing.M) {
+ config.SetConsumerService(grpcGreeterImpl)
+ config.Load()
+ time.Sleep(3 * time.Second)
+
+ os.Exit(m.Run())
+}
diff --git a/route/meshroute/README.md b/route/meshroute/README.md
new file mode 100644
index 0000000..ea800c9
--- /dev/null
+++ b/route/meshroute/README.md
@@ -0,0 +1,9 @@
+# Mesh Route for Dubbo-go 3.0
+
+For api definition and go client and server startup, please refer to [dubbo-go 3.0 quickstart](https://dubbogo.github.io/zh-cn/docs/user/quickstart/3.0/quickstart.html)
+
+## Instructions
+1. Start `zookeeper` service by docker with `integrate_test/dockercompose/docker-compose.yml` or executable binary file.
+2. Start the server service.
+3. Get dynamic configuration and publish mesh route config.
+4. Use the client to call the server-side service.
\ No newline at end of file
diff --git a/route/meshroute/README_zh.md b/route/meshroute/README_zh.md
new file mode 100644
index 0000000..c0f42e2
--- /dev/null
+++ b/route/meshroute/README_zh.md
@@ -0,0 +1,9 @@
+# Helloworld for Dubbo-go 3.0
+
+api 定义以及 go 客户端、服务端启动,可以参考 [dubbo-go 3.0 快速开始](https://dubbogo.github.io/zh-cn/docs/user/quickstart/3.0/quickstart.html)
+
+## 使用方法
+1. 可以使用 docker 结合 `integrate_test/dockercompose/docker-compose.yml` 文件或下载官网的二进制文件启动 zookeeper 服务。
+2. 启动服务端服务。
+3. 获取动态配置中心,并发布 mesh 路由配置。
+4. 使用客户端调用服务端发布的服务。
\ No newline at end of file
diff --git a/route/meshroute/go-client/cmd/client.go b/route/meshroute/go-client/cmd/client.go
new file mode 100644
index 0000000..f1fcf15
--- /dev/null
+++ b/route/meshroute/go-client/cmd/client.go
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "context"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/common/logger"
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+)
+
+import (
+ "github.com/apache/dubbo-go-samples/api"
+)
+
+const MeshRouteConf = "apiVersion: service.dubbo.apache.org/v1alpha1\n" +
+ "kind: DestinationRule\n" +
+ "metadata: { name: demo-route }\n" +
+ "spec:\n" +
+ " host: demo\n" +
+ " subsets:\n" +
+ " - labels: { env-sign: xxx, tag1: hello }\n" +
+ " name: isolation\n" +
+ " - labels: { env-sign: yyy }\n" +
+ " name: testing-trunk\n" +
+ " - labels: { env-sign: zzz }\n" +
+ " name: testing\n" +
+ " trafficPolicy:\n" +
+ " loadBalancer: { simple: ROUND_ROBIN }\n\n" +
+ "---\n\n" +
+ "apiVersion: service.dubbo.apache.org/v1alpha1\n" +
+ "kind: VirtualService\n" +
+ "metadata: {name: demo-route}\n" +
+ "spec:\n" +
+ " dubbo:\n" +
+ " - routedetail:\n" +
+ " - match:\n" +
+ " - sourceLabels: {trafficLabel: xxx}\n" +
+ " name: xxx-project\n" +
+ " route:\n" +
+ " - destination: {host: demo, subset: isolation}\n" +
+ " - match:\n" +
+ " - sourceLabels: {trafficLabel: testing-trunk}\n" +
+ " name: testing-trunk\n" +
+ " route:\n" +
+ " - destination: {host: demo, subset: testing-trunk}\n" +
+ " - name: testing\n" +
+ " route:\n" +
+ " - destination: {host: demo, subset: testing}\n" +
+ " services:\n" +
+ " - {exact: com.apache.dubbo.sample.basic.IGreeter}\n" +
+ " hosts: [demo]"
+
+var grpcGreeterImpl = &api.GreeterClientImpl{}
+
+// export DUBBO_GO_CONFIG_PATH= PATH_TO_SAMPLES/route/meshroute/go-client/conf/dubbogo.yml
+func main() {
+ config.SetConsumerService(grpcGreeterImpl)
+ if err := config.Load(); err != nil {
+ panic(err)
+ }
+
+ dynamicConfiguration, err := config.GetRootConfig().ConfigCenter.GetDynamicConfiguration()
+ if err != nil {
+ panic(err)
+ }
+
+ // publish mesh route config
+ err = dynamicConfiguration.PublishConfig("dubbo.io.MESHAPPRULE", "dubbo", MeshRouteConf)
+ if err != nil {
+ return
+ }
+
+ logger.Info("start to test dubbo")
+ req := &api.HelloRequest{
+ Name: "Dong",
+ }
+ reply, err := grpcGreeterImpl.SayHello(context.Background(), req)
+ if err != nil {
+ logger.Error(err)
+ }
+ logger.Infof("client response result: %v\n", reply)
+}
diff --git a/route/meshroute/go-client/conf/dubbogo.yml b/route/meshroute/go-client/conf/dubbogo.yml
new file mode 100644
index 0000000..64c0aac
--- /dev/null
+++ b/route/meshroute/go-client/conf/dubbogo.yml
@@ -0,0 +1,17 @@
+dubbo:
+ registries:
+ demoZK:
+ protocol: zookeeper
+ timeout: 3s
+ address: 127.0.0.1:2181
+ consumer:
+ registryIDs:
+ - demoZK
+ references:
+ GreeterClientImpl:
+ protocol: tri
+ interface: com.apache.dubbo.sample.basic.IGreeter # must be compatible with grpc or dubbo-java
+ config-center:
+ protocol: zookeeper
+ address: 127.0.0.1:2181
+ data-id: "dubbo-go-samples-configcenter-zookeeper-client"
\ No newline at end of file
diff --git a/route/meshroute/go-client/conf/mesh_route.yml b/route/meshroute/go-client/conf/mesh_route.yml
new file mode 100644
index 0000000..76af336
--- /dev/null
+++ b/route/meshroute/go-client/conf/mesh_route.yml
@@ -0,0 +1,39 @@
+apiVersion: service.dubbo.apache.org/v1alpha1
+kind: DestinationRule
+metadata: { name: demo-route }
+spec:
+ host: demo
+ subsets:
+ - labels: { env-sign: xxx, tag1: hello }
+ name: isolation
+ - labels: { env-sign: yyy }
+ name: testing-trunk
+ - labels: { env-sign: zzz }
+ name: testing
+ trafficPolicy:
+ loadBalancer: { simple: ROUND_ROBIN }
+
+---
+
+apiVersion: service.dubbo.apache.org/v1alpha1
+kind: VirtualService
+metadata: {name: demo-route}
+spec:
+ dubbo:
+ - routedetail:
+ - match:
+ - sourceLabels: {trafficLabel: xxx}
+ name: xxx-project
+ route:
+ - destination: {host: demo, subset: isolation}
+ - match:
+ - sourceLabels: {trafficLabel: testing-trunk}
+ name: testing-trunk
+ route:
+ - destination: {host: demo, subset: testing-trunk}
+ - name: testing
+ route:
+ - destination: {host: demo, subset: testing}
+ services:
+ - {exact: com.apache.dubbo.sample.basic.IGreeter}
+ hosts: [demo]
diff --git a/route/meshroute/go-server/cmd/server.go b/route/meshroute/go-server/cmd/server.go
new file mode 100644
index 0000000..76e3e51
--- /dev/null
+++ b/route/meshroute/go-server/cmd/server.go
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "context"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/common/logger"
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+)
+
+import (
+ "github.com/apache/dubbo-go-samples/api"
+)
+
+type GreeterProvider struct {
+ api.GreeterProviderBase
+}
+
+func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) {
+ logger.Infof("Dubbo3 GreeterProvider get user name = %s\n", in.Name)
+ return &api.User{Name: "Hello " + in.Name, Id: "12345", Age: 21}, nil
+}
+
+// export DUBBO_GO_CONFIG_PATH= PATH_TO_SAMPLES/route/meshroute/go-server/conf/dubbogo.yml
+func main() {
+ config.SetProviderService(&GreeterProvider{})
+ if err := config.Load(); err != nil {
+ panic(err)
+ }
+ select {}
+}
diff --git a/route/meshroute/go-server/conf/dubbogo.yml b/route/meshroute/go-server/conf/dubbogo.yml
new file mode 100644
index 0000000..b9e6bd2
--- /dev/null
+++ b/route/meshroute/go-server/conf/dubbogo.yml
@@ -0,0 +1,23 @@
+dubbo:
+ registries:
+ demoZK:
+ protocol: zookeeper
+ timeout: 3s
+ address: 127.0.0.1:2181
+ protocols:
+ triple:
+ name: tri
+ port: 20000
+ provider:
+ registryIDs:
+ - demoZK
+ services:
+ GreeterProvider:
+ protocolIDs: triple
+ interface: com.apache.dubbo.sample.basic.IGreeter # must be compatible with grpc or dubbo-java
+ params:
+ env-sign: yyy
+ config-center:
+ protocol: zookeeper
+ address: 127.0.0.1:2181
+ data-id: dubbo-go-samples-configcenter-zookeeper-client
diff --git a/start_integrate_test.sh b/start_integrate_test.sh
index 5c561d2..ea963c6 100755
--- a/start_integrate_test.sh
+++ b/start_integrate_test.sh
@@ -18,8 +18,11 @@
array+=("game/go-server-game")
array+=("game/go-server-gate")
+# route
+array=("route/meshroute")
+
# helloworld
-array=("helloworld")
+array+=("helloworld")
# direct
array+=("direct")
@@ -51,7 +54,6 @@ array+=("rpc/triple/pb/dubbogo-grpc")
array+=("rpc/grpc")
array+=("rpc/jsonrpc")
-
DOCKER_DIR=$(pwd)/integrate_test/dockercompose
docker-compose -f $DOCKER_DIR/docker-compose.yml up -d
bash -f $DOCKER_DIR/docker-health-check.sh
diff --git a/tracing/README.md b/tracing/README.md
index eb88ef8..5b6006c 100644
--- a/tracing/README.md
+++ b/tracing/README.md
@@ -3,7 +3,7 @@
If u wanna know how to startup the client/server and the definition of APIs, please refer to [dubbo-go 3.0 quickstart](https://dubbogo.github.io/zh-cn/docs/user/quickstart/3.0/quickstart.html)
## Instructions
-1. Start `zookeeper` service in `docker/docker-compose.yml` file
+1. Start `zookeeper` service in `integrate_test/dockercompose/docker-compose.yml` file
2. Start the server side.
1. Find the go-server folder, run the `main` function under the cmd package, and start the golang server
3. Start the client side.