This is an automated email from the ASF dual-hosted git repository.
xuetaoli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
The following commit(s) were added to refs/heads/main by this push:
new 038cc416 Revert "impl: delete all polaris related content (#860)"
(#865)
038cc416 is described below
commit 038cc416eefd3de4b858e5123d2179d6a7bfa04d
Author: marsevilspirit <[email protected]>
AuthorDate: Sun Nov 30 22:09:41 2025 +0800
Revert "impl: delete all polaris related content (#860)" (#865)
This reverts commit 2bae17fefea2a0baa8f94fcb89a3254f6a3776d4.
Co-authored-by: Xuetao Li <[email protected]>
---
README.md | 2 +-
README_CN.md | 2 +-
compatibility/polaris/limit/README-zh.md | 91 ++++++++++++++++
compatibility/polaris/limit/README.md | 91 ++++++++++++++++
compatibility/polaris/limit/go-client/cmd/main.go | 84 ++++++++++++++
.../polaris/limit/go-client/conf/dubbogo.yml | 24 ++++
.../polaris/limit/go-server/cmd/server.go | 111 +++++++++++++++++++
.../polaris/limit/go-server/conf/dubbogo.yml | 29 +++++
.../limit/images/dubbogo-ratelimit-rule.png | Bin 0 -> 113890 bytes
compatibility/polaris/registry/README-zh.md | 62 +++++++++++
compatibility/polaris/registry/README.md | 61 +++++++++++
.../polaris/registry/go-client/cmd/main.go | 81 ++++++++++++++
.../polaris/registry/go-client/conf/dubbogo.yml | 24 ++++
.../polaris/registry/go-server/cmd/server.go | 110 +++++++++++++++++++
.../polaris/registry/go-server/conf/dubbogo.yml | 27 +++++
compatibility/polaris/router/README-zh.md | 121 +++++++++++++++++++++
compatibility/polaris/router/README.md | 121 +++++++++++++++++++++
compatibility/polaris/router/go-client/cmd/main.go | 81 ++++++++++++++
.../polaris/router/go-client/conf/dubbogo.yaml | 25 +++++
.../router/go-server/server-dev/cmd/server.go | 111 +++++++++++++++++++
.../router/go-server/server-dev/conf/dubbogo.yaml | 28 +++++
.../router/go-server/server-pre/cmd/server.go | 111 +++++++++++++++++++
.../router/go-server/server-pre/conf/dubbogo.yaml | 28 +++++
.../router/go-server/server-prod/cmd/server.go | 111 +++++++++++++++++++
.../router/go-server/server-prod/conf/dubbogo.yaml | 28 +++++
.../router/images/dubbogo-route-rule-dev.png | Bin 0 -> 103117 bytes
.../router/images/dubbogo-route-rule-pre.png | Bin 0 -> 102704 bytes
.../router/images/dubbogo-route-rule-prod.png | Bin 0 -> 97770 bytes
.../rpc/triple/tests/integration/main_test.go | 1 +
.../limit/tests/integration/limit_test.go} | 38 +++----
.../limit}/tests/integration/main_test.go | 48 +++++---
.../registry}/tests/integration/main_test.go | 48 +++++---
.../registry/tests/integration/registry_test.go} | 36 +++---
integrate_test/dockercompose/docker-compose.yml | 12 ++
start_integrate_test.sh | 4 +
35 files changed, 1670 insertions(+), 81 deletions(-)
diff --git a/README.md b/README.md
index bd35f7e2..d8894a2f 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,7 @@ A collection of runnable Dubbo-go examples covering
configuration, registries, o
* `otel/tracing`: Distributed tracing examples using OpenTelemetry.
* `stdout`: Uses stdout exporter to export tracing data.
* `otlp_http_exporter`: Uses `otlpHttpExporter` to export tracing data,
covering `dubbo`/`triple`/`jsonrpc` protocols.
-* `registry`: Examples of using different service registries (e.g., Nacos,
Zookeeper).
+* `registry`: Examples of using different service registries (e.g., Nacos,
Zookeeper, Polaris).
* `retry`: Demonstrates retry mechanisms in Dubbo-go RPC calls.
* `rpc`: Various RPC protocol examples with Dubbo-go.
* `rpc/dubbo`: Dubbo protocol example, including Java–Go interop.
diff --git a/README_CN.md b/README_CN.md
index 1b990262..40763d36 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -31,7 +31,7 @@
* `otel/tracing`:使用 OpenTelemetry 的分布式链路追踪示例。
* `stdout`:使用 stdout exporter 输出追踪数据。
* `otlp_http_exporter`:使用 `otlpHttpExporter` 导出追踪数据,覆盖 `dubbo` / `triple` /
`jsonrpc` 协议。
-* `registry`:使用不同服务注册中心(如 Nacos、Zookeeper)的示例。
+* `registry`:使用不同服务注册中心(如 Nacos、Zookeeper、Polaris)的示例。
* `retry`:Dubbo-go RPC 调用重试机制示例。
* `rpc`:Dubbo-go 支持的多种 RPC 协议示例。
* `rpc/dubbo`:Dubbo 协议示例,包含 Java–Go 互操作。
diff --git a/compatibility/polaris/limit/README-zh.md
b/compatibility/polaris/limit/README-zh.md
new file mode 100644
index 00000000..ea1cec86
--- /dev/null
+++ b/compatibility/polaris/limit/README-zh.md
@@ -0,0 +1,91 @@
+# Dubbo Go & Polaris TpsLimiter Example
+
+[English](README.md) | 中文
+
+## 使用服务限流功能
+
+在 dubbogo 中快速体验北极星的服务限流能力
+
+## 北极星服务端安装
+
+[北极星服务端单机版本安装文档](https://polarismesh.cn/docs/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/%E5%8D%95%E6%9C%BA%E7%89%88%E5%AE%89%E8%A3%85/)
+
+[北极星服务端集群版本安装文档](https://polarismesh.cn/docs/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/%E9%9B%86%E7%BE%A4%E7%89%88%E5%AE%89%E8%A3%85/)
+
+## 如何使用
+
+[北极星服务限流使用文档](https://polarismesh.cn/docs/%E5%8C%97%E6%9E%81%E6%98%9F%E6%98%AF%E4%BB%80%E4%B9%88/%E5%8A%9F%E8%83%BD%E7%89%B9%E6%80%A7/%E6%B5%81%E9%87%8F%E7%AE%A1%E7%90%86/#%E8%AE%BF%E9%97%AE%E9%99%90%E6%B5%81)
+
+### dubbogo.yaml 配置文件
+
+在使用 PolarisMesh 的服务限流能力时,需要先启用 PolarisMesh 在 dubbogo 中的注册发现功能。
+
+```yaml
+dubbo:
+ registries:
+ polarisMesh:
+ protocol: polaris
+ address: ${北极星服务端IP}:8091
+ namespace: ${北极星命名空间信息}
+ token: ${北极星资源鉴权 token} # 如果北极星服务端开启了针对客户端的鉴权,则需要配置该参数
+ provider:
+ services:
+ UserProvider:
+ interface: org.apache.dubbo.UserProvider.Test
+ tps.limiter: polaris-limit # 配置 tps.limiter 为 polaris-limiter 即可
+
+```
+
+注意:PolarisMesh 的服务限流能力是工作在 Provider 侧的。
+
+### 如何配置服务限流参数
+
+dubbogo 中的 PolarisMesh TpsLimiter 扩展点实现,能够根据用户配置的限流规则,自动的从当前 RPC
调用上下文以及请求信息中识别出需要参与限流的请求标签信息
+
+
+
+- 请求匹配规则为 **请求参数(QUERY)**
+ - 标签来源: RPC 调用中方法的入参,即 Invoaction.Arguments()
+ - 标签键规则
+ - 方法仅有一个入参: param.$.${fieldName}, **param.** 为固定前缀,后面的表达式为标准的 JSONPath
expressions,[参考文档](https://goessner.net/articles/JsonPath/)
+ - 方法有多个参数: param[${index}].$.${fieldName}, **param[${index}].**
为固定前缀,${index} 代表是方法入参中的第几个参数,下标起始位置从 0 开始;后面的表达式为标准的 JSONPath
expressions,[参考文档](https://goessner.net/articles/JsonPath/)
+- 请求匹配规则为 **请求头(HEADER)**:
+ - 标签来源: RPC 调用的额外标签信息,即 Invoaction.Attachments()
+
+### 运行服务提供者
+
+进入 go-server 的 cmd 目录,执行以下命令
+
+```
+ export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yaml"
+ go run .
+```
+
+当看到以下日志时即表示 server 端启动成功
+
+```log
+INFO dubbo/dubbo_protocol.go:84 [DUBBO Protocol] Export service:
+```
+
+
+### 运行服务调用者
+
+进入 go-client 的 cmd 目录,执行以下命令
+
+
+```
+ export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+ go run .
+```
+
+当看到以下日志时即表示 go-client 成功发现 go-server 并发起了 RPC 调用
+
+```log
+INFO cmd/main.go:75 response: &{A001 Alex Stocks 18 2022-11-19
12:52:38.092 +0800 CST}
+```
+
+当看到以下日志时即表示在 PolarisMesh 针对 go-server 配置的限流策略已生效
+
+```log
+ERROR handler/rejected_execution_handler_only_log.go:73 The invocation
was rejected
+```
diff --git a/compatibility/polaris/limit/README.md
b/compatibility/polaris/limit/README.md
new file mode 100644
index 00000000..11c2bb89
--- /dev/null
+++ b/compatibility/polaris/limit/README.md
@@ -0,0 +1,91 @@
+# Dubbo Go & Polaris TpsLimiter Example
+
+English | [中文](README-zh.md)
+
+## Use the service current limit function
+
+Quickly experience Polaris' service current limiting capabilities in dubbogo
+
+## Polaris server installation
+
+[Polaris Server Standalone Version Installation
Documentation](https://polarismesh.cn/docs/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/%E5%8D%95%E6%9C%BA%E7%89%88%E5%AE%89%E8%A3%85/)
+
+[Polaris Server Cluster Version Installation
Documentation](https://polarismesh.cn/docs/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/%E9%9B%86%E7%BE%A4%E7%89%88%E5%AE%89%E8%A3%85/)
+
+## how to use
+
+[Polaris Service Current Limitation
Documentation](https://polarismesh.cn/docs/%E5%8C%97%E6%9E%81%E6%98%9F%E6%98%AF%E4%BB%80%E4%B9%88/%E5%8A%9F%E8%83%BD%E7%89%B9%E6%80%A7/%E6%B5%81%E9%87%8F%E7%AE%A1%E7%90%86/#%E8%AE%BF%E9%97%AE%E9%99%90%E6%B5%81)
+
+### dubbogo.yaml configuration file
+
+When using PolarisMesh's service current limiting capability, you need to
enable PolarisMesh's registration discovery function in dubbogo firstly.
+
+````yaml
+dubbo:
+ registries:
+ polarisMesh:
+ protocol: polaris
+ address: ${Polaris server IP}:8091
+ namespace: ${Polaris namespace information}
+ token: ${Polaris resource authentication token} # If the Polaris server
has enabled authentication for the client, you need to configure this parameter
+ provider:
+ services:
+ UserProvider:
+ interface: org.apache.dubbo.UserProvider.Test
+ tps.limiter: polaris-limit # Configure tps.limiter as polaris-limiter
+
+````
+
+Note: The service current limiting capability of PolarisMesh works on the
Provider side.
+
+### How to configure service current limit parameters
+
+The implementation of the PolarisMesh TpsLimiter extension point in dubbogo
can automatically identify the request tag information that needs to
participate in current limiting from the current RPC call context and request
information according to the current limiting rules configured by the user.
+
+
+
+- The request matching rule is **Request parameter(QUERY)**
+ - Tag source: the input parameter of the method in the RPC call, namely
Invoaction.Arguments()
+ - Tag key rules
+ - The method has only one input parameter: param.$.${fieldName},
**param.** is a fixed prefix, the following expressions are standard JSONPath
expressions, [reference document](https://goessner.net/ articles/JsonPath/)
+ - The method has multiple parameters: param[${index}].$.${fieldName},
**param[${index}].** is a fixed prefix, ${index} represents the first parameter
in the method parameter Several parameters, the starting position of the
subscript starts from 0; the following expressions are standard JSONPath
expressions, [reference document](https://goessner.net/articles/JsonPath/)
+- The request matching rule is **request header (HEADER)**:
+ - Tag source: Additional tag information for RPC calls, i.e.
Invoaction.Attachments()
+
+### Running the service provider
+
+Enter the cmd directory of go-server and execute the following command
+
+````
+ export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+ go run .
+````
+
+When you see the following log, it means that the server side started
successfully
+
+````log
+INFO dubbo/dubbo_protocol.go:84 [DUBBO Protocol] Export service:
+````
+
+
+### Run the service caller
+
+Enter the cmd directory of go-client and execute the following command
+
+
+````
+ export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+ go run .
+````
+
+When you see the following log, it means that go-client successfully
discovered go-server and made an RPC call
+
+````log
+INFO cmd/main.go:75 response: &{A001 Alex Stocks 18 2022-11-19 12:52:38.092
+0800 CST}
+````
+
+When you see the following log, it means that the current limiting policy
configured for go-server in PolarisMesh has taken effect
+
+````log
+ERROR handler/rejected_execution_handler_only_log.go:73 The invocation was
rejected
+````
\ No newline at end of file
diff --git a/compatibility/polaris/limit/go-client/cmd/main.go
b/compatibility/polaris/limit/go-client/cmd/main.go
new file mode 100644
index 00000000..4acd43cb
--- /dev/null
+++ b/compatibility/polaris/limit/go-client/cmd/main.go
@@ -0,0 +1,84 @@
+/*
+ * 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"
+ "errors"
+ "time"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+
+ hessian "github.com/apache/dubbo-go-hessian2"
+
+ "github.com/dubbogo/gost/log/logger"
+)
+
+type UserProviderWithCustomGroupAndVersion struct {
+ GetUser func(ctx context.Context, req *User) (rsp *User, err error)
+}
+
+type UserProvider struct {
+ GetUser func(ctx context.Context, req *User) (rsp *User, err error)
+}
+
+type User struct {
+ ID string
+ Name string
+ Age int32
+ Time time.Time
+}
+
+func (u *User) JavaClassName() string {
+ return "org.apache.dubbo.User"
+}
+
+func main() {
+ var userProvider = &UserProvider{}
+ var userProviderWithCustomRegistryGroupAndVersion =
&UserProviderWithCustomGroupAndVersion{}
+ config.SetConsumerService(userProvider)
+ config.SetConsumerService(userProviderWithCustomRegistryGroupAndVersion)
+ hessian.RegisterPOJO(&User{})
+ err := config.Load()
+ if err != nil {
+ panic(err)
+ }
+
+ logger.Infof("\n\n\nstart to test dubbo")
+
+ var successCount, failCount int64
+ for i := 0; i < 10; i++ {
+ time.Sleep(50 * time.Millisecond)
+ user, err := userProvider.GetUser(context.TODO(), &User{Name:
"Alex03"})
+ if err != nil {
+ failCount++
+ logger.Infof("error: %v\n", err)
+ } else {
+ successCount++
+ }
+ logger.Infof("response: %v\n", user)
+ }
+ logger.Infof("successCount=%v, failCount=%v\n", successCount, failCount)
+
+ if failCount == 0 {
+ panic(errors.New("need failCount > 0"))
+ }
+}
diff --git a/compatibility/polaris/limit/go-client/conf/dubbogo.yml
b/compatibility/polaris/limit/go-client/conf/dubbogo.yml
new file mode 100644
index 00000000..294de217
--- /dev/null
+++ b/compatibility/polaris/limit/go-client/conf/dubbogo.yml
@@ -0,0 +1,24 @@
+dubbo:
+ application:
+ name: myApp # metadata: application=myApp; name=myApp
+ module: opensource #metadata: module=opensource
+ group: myAppGroup # no metadata record
+ organization: dubbo # metadata: organization=dubbo
+ owner: laurence # metadata: owner=laurence
+ version: myversion # metadata: app.version=myversion
+ environment: pro # metadata: environment=pro
+ registries:
+ polarisMesh:
+ protocol: polaris
+ address: 127.0.0.1:8091
+ namespace: dubbogo
+ registry-type: interface
+ consumer:
+ references:
+ UserProvider:
+ protocol: dubbo
+ interface: org.apache.dubbo.UserProvider.Test
+ UserProviderWithCustomGroupAndVersion:
+ protocol: dubbo
+ interface: org.apache.dubbo.UserProvider.Test2
+ version: myInterfaceVersion # dubbo interface version must be same
with server
diff --git a/compatibility/polaris/limit/go-server/cmd/server.go
b/compatibility/polaris/limit/go-server/cmd/server.go
new file mode 100644
index 00000000..6272c16d
--- /dev/null
+++ b/compatibility/polaris/limit/go-server/cmd/server.go
@@ -0,0 +1,111 @@
+/*
+ * 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"
+ "fmt"
+ "os"
+ "os/signal"
+ "syscall"
+ "time"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/filter/tps/strategy"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+
+ hessian "github.com/apache/dubbo-go-hessian2"
+
+ "github.com/dubbogo/gost/log/logger"
+)
+
+var (
+ survivalTimeout = int(3e9)
+)
+
+func init() {
+ config.SetProviderService(&UserProvider{})
+ config.SetProviderService(&UserProviderWithCustomGroupAndVersion{})
+ // ------for hessian2------
+ hessian.RegisterPOJO(&User{})
+}
+
+type User struct {
+ ID string
+ Name string
+ Age int32
+ Time time.Time
+}
+
+type UserProvider struct {
+}
+
+func (u *UserProvider) GetUser(ctx context.Context, req *User) (*User, error) {
+ logger.Infof("req:%#v", req)
+ rsp := User{"A001", "Alex Stocks", 18, time.Now()}
+ logger.Infof("rsp:%#v", rsp)
+ return &rsp, nil
+}
+
+func (u *User) JavaClassName() string {
+ return "org.apache.dubbo.User"
+}
+
+type UserProviderWithCustomGroupAndVersion struct {
+}
+
+func (u *UserProviderWithCustomGroupAndVersion) GetUser(ctx context.Context,
req *User) (*User, error) {
+ logger.Infof("req:%#v", req)
+ rsp := User{"A001", "Alex Stocks from
UserProviderWithCustomGroupAndVersion", 18, time.Now()}
+ logger.Infof("rsp:%#v", rsp)
+ return &rsp, nil
+}
+
+// need to setup environment variable "CONF_PROVIDER_FILE_PATH" to
"conf/server.yml" before run
+func main() {
+ if err := config.Load(); err != nil {
+ panic(err)
+ }
+
+ initSignal()
+}
+
+func initSignal() {
+ signals := make(chan os.Signal, 1)
+ // It is not possible to block SIGKILL or syscall.SIGSTOP
+ signal.Notify(signals, os.Interrupt, syscall.SIGHUP, syscall.SIGQUIT,
syscall.SIGTERM)
+ for {
+ sig := <-signals
+ logger.Infof("get signal %s", sig.String())
+ switch sig {
+ case syscall.SIGHUP:
+ // reload()
+ default:
+ time.AfterFunc(time.Duration(survivalTimeout), func() {
+ logger.Warnf("app exit now by force...")
+ os.Exit(1)
+ })
+
+ // The program exits normally or timeout forcibly exits.
+ fmt.Println("provider app exit now...")
+ return
+ }
+ }
+}
diff --git a/compatibility/polaris/limit/go-server/conf/dubbogo.yml
b/compatibility/polaris/limit/go-server/conf/dubbogo.yml
new file mode 100644
index 00000000..2aa7785d
--- /dev/null
+++ b/compatibility/polaris/limit/go-server/conf/dubbogo.yml
@@ -0,0 +1,29 @@
+dubbo:
+ application:
+ name: myApp # metadata: application=myApp; name=myApp
+ module: opensource #metadata: module=opensource
+ group: myAppGroup # no metadata record
+ organization: dubbo # metadata: organization=dubbo
+ owner: laurence # metadata: owner=laurence
+ version: myversion # metadata: app.version=myversion
+ environment: pro # metadata: environment=pro
+ registries:
+ polarisMesh:
+ protocol: polaris
+ address: 127.0.0.1:8091
+ namespace: dubbogo
+ registry-type: interface
+ protocols:
+ dubbo:
+ name: dubbo
+ port: 20000
+ provider:
+ services:
+ UserProvider:
+ interface: org.apache.dubbo.UserProvider.Test
+ tps.limiter: polaris-limit # the Limiter that judge if the TPS overs
the threshold, such as method-service or default
+ UserProviderWithCustomGroupAndVersion:
+ interface: org.apache.dubbo.UserProvider.Test2
+ version: myInterfaceVersion # dubbo interface version must be same
with client
+ group: myInterfaceGroup # dubbo interface group must be same with
client
+ tps.limiter: polaris-limit # the Limiter that judge if the TPS overs
the threshold, such as method-service or default
diff --git a/compatibility/polaris/limit/images/dubbogo-ratelimit-rule.png
b/compatibility/polaris/limit/images/dubbogo-ratelimit-rule.png
new file mode 100644
index 00000000..efdd51ba
Binary files /dev/null and
b/compatibility/polaris/limit/images/dubbogo-ratelimit-rule.png differ
diff --git a/compatibility/polaris/registry/README-zh.md
b/compatibility/polaris/registry/README-zh.md
new file mode 100644
index 00000000..a13c2aab
--- /dev/null
+++ b/compatibility/polaris/registry/README-zh.md
@@ -0,0 +1,62 @@
+# Dubbo Go & Polaris Registry Example
+
+English | [中文](README-zh.md)
+
+## 使用服务注册发现功能
+
+在 dubbogo 中快速体验北极星的服务注册以及服务发现能力
+
+## 北极星服务端安装
+
+[北极星服务端单机版本安装文档](https://polarismesh.cn/docs/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/%E5%8D%95%E6%9C%BA%E7%89%88%E5%AE%89%E8%A3%85/)
+
+[北极星服务端集群版本安装文档](https://polarismesh.cn/docs/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/%E9%9B%86%E7%BE%A4%E7%89%88%E5%AE%89%E8%A3%85/)
+
+## 如何使用
+
+### dubbogo.yaml 配置文件
+
+当前 PolarisMesh 已实现了 dubbogo 的注册发现扩展点,因此你只需要调整你的 dubbogo.yaml 文件中的 registries
配置项,新增 protocol 为 polaris 的注册中心配置即可,可以参考下面的样例。
+
+```yaml
+dubbo:
+ registries:
+ polarisMesh:
+ protocol: polaris
+ address: ${北极星服务端IP}:8091
+ namespace: ${北极星命名空间信息}
+ token: ${北极星资源鉴权 token} # 如果北极星服务端开启了针对客户端的鉴权,则需要配置该参数
+```
+
+### 运行服务提供者
+
+进入 go-server 的 cmd 目录,执行以下命令
+
+```
+ export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+ go run .
+```
+
+当看到以下日志时即表示 server 端启动成功
+
+```log
+INFO dubbo/dubbo_protocol.go:84 [DUBBO Protocol] Export service:
+```
+
+
+### 运行服务调用者
+
+进入 go-client 的 cmd 目录,执行以下命令
+
+
+```
+ export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+ go run .
+```
+
+当看到以下日志时即表示 go-client 成功发现 go-server 并发起了 RPC 调用
+
+```log
+INFO cmd/main.go:75 response: &{A001 Alex Stocks 18 2022-11-19
12:52:38.092 +0800 CST}
+```
+
diff --git a/compatibility/polaris/registry/README.md
b/compatibility/polaris/registry/README.md
new file mode 100644
index 00000000..e6ea563f
--- /dev/null
+++ b/compatibility/polaris/registry/README.md
@@ -0,0 +1,61 @@
+# Dubbo Go & Polaris Registry Example
+
+English | [中文](README-zh.md)
+
+## Using the service registration discovery function
+
+Quickly experience Polaris' service registration and service discovery
capabilities in dubbogo
+
+## Polaris server installation
+
+[Polaris Server Standalone Version Installation
Documentation](https://polarismesh.cn/docs/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/%E5%8D%95%E6%9C%BA%E7%89%88%E5%AE%89%E8%A3%85/)
+
+[Polaris Server Cluster Version Installation
Documentation](https://polarismesh.cn/docs/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/%E9%9B%86%E7%BE%A4%E7%89%88%E5%AE%89%E8%A3%85/)
+
+## how to use
+
+### dubbogo.yaml configuration file
+
+Currently PolarisMesh has implemented the registration discovery extension
point of dubbogo, so you only need to adjust the registries configuration item
in your dubbogo.yaml file, and add the registry configuration of polaris as the
protocol. You can refer to the following example.
+
+````yaml
+dubbo:
+ registries:
+ polarisMesh:
+ protocol: polaris
+ address: ${Polaris server IP}:8091
+ namespace: ${Polaris namespace information}
+ token: ${Polaris resource authentication token} # If the Polaris server
has enabled authentication for the client, you need to configure this parameter
+````
+
+### Running the service provider
+
+Enter the cmd directory of go-server and execute the following command
+
+````
+ export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+ go run .
+````
+
+When you see the following log, it means that the server side started
successfully
+
+````log
+INFO dubbo/dubbo_protocol.go:84 [DUBBO Protocol] Export service:
+````
+
+
+### Run the service caller
+
+Enter the cmd directory of go-client and execute the following command
+
+
+````
+ export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+ go run .
+````
+
+When you see the following log, it means that go-client successfully
discovered go-server and made an RPC call
+
+````log
+INFO cmd/main.go:75 response: &{A001 Alex Stocks 18 2022-11-19 12:52:38.092
+0800 CST}
+````
\ No newline at end of file
diff --git a/compatibility/polaris/registry/go-client/cmd/main.go
b/compatibility/polaris/registry/go-client/cmd/main.go
new file mode 100644
index 00000000..e685d8a4
--- /dev/null
+++ b/compatibility/polaris/registry/go-client/cmd/main.go
@@ -0,0 +1,81 @@
+/*
+ * 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"
+ "os"
+ "time"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+
+ hessian "github.com/apache/dubbo-go-hessian2"
+
+ "github.com/dubbogo/gost/log/logger"
+)
+
+type UserProviderWithCustomGroupAndVersion struct {
+ GetUser func(ctx context.Context, req *User) (rsp *User, err error)
+}
+
+type UserProvider struct {
+ GetUser func(ctx context.Context, req *User) (rsp *User, err error)
+}
+
+type User struct {
+ ID string
+ Name string
+ Age int32
+ Time time.Time
+}
+
+func (u *User) JavaClassName() string {
+ return "org.apache.dubbo.User"
+}
+
+func main() {
+ var userProvider = &UserProvider{}
+ var userProviderWithCustomRegistryGroupAndVersion =
&UserProviderWithCustomGroupAndVersion{}
+ config.SetConsumerService(userProvider)
+ config.SetConsumerService(userProviderWithCustomRegistryGroupAndVersion)
+ hessian.RegisterPOJO(&User{})
+ err := config.Load()
+ if err != nil {
+ panic(err)
+ }
+
+ logger.Infof("\n\n\nstart to test dubbo")
+ user, err := userProvider.GetUser(context.TODO(), &User{Name:
"Alex001"})
+ if err != nil {
+ logger.Errorf("error: %v\n", err)
+ os.Exit(1)
+ return
+ }
+ logger.Infof("response result: %v\n", user)
+
+ user, err =
userProviderWithCustomRegistryGroupAndVersion.GetUser(context.TODO(),
&User{Name: "Alex001"})
+ if err != nil {
+ logger.Errorf("error: %v\n", err)
+ os.Exit(1)
+ return
+ }
+ logger.Infof("response result: %v\n", user)
+}
diff --git a/compatibility/polaris/registry/go-client/conf/dubbogo.yml
b/compatibility/polaris/registry/go-client/conf/dubbogo.yml
new file mode 100644
index 00000000..068e6dd4
--- /dev/null
+++ b/compatibility/polaris/registry/go-client/conf/dubbogo.yml
@@ -0,0 +1,24 @@
+dubbo:
+ application:
+ name: myApp # metadata: application=myApp; name=myApp
+ module: opensource #metadata: module=opensource
+ group: myAppGroup # no metadata record
+ organization: dubbo # metadata: organization=dubbo
+ owner: laurence # metadata: owner=laurence
+ version: myversion # metadata: app.version=myversion
+ environment: pro # metadata: environment=pro
+ registries:
+ polarisMesh:
+ protocol: polaris
+ address: 127.0.0.1:8091
+ namespace: dubbogo
+ registry-type: interface
+ consumer:
+ references:
+ UserProvider:
+ protocol: dubbo
+ interface: org.apache.dubbo.UserProvider.Test
+ UserProviderWithCustomGroupAndVersion:
+ protocol: dubbo
+ interface: org.apache.dubbo.UserProvider.Test2
+ version: myInterfaceVersion # dubbo interface version must be same
with server
\ No newline at end of file
diff --git a/compatibility/polaris/registry/go-server/cmd/server.go
b/compatibility/polaris/registry/go-server/cmd/server.go
new file mode 100644
index 00000000..55988678
--- /dev/null
+++ b/compatibility/polaris/registry/go-server/cmd/server.go
@@ -0,0 +1,110 @@
+/*
+ * 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"
+ "fmt"
+ "os"
+ "os/signal"
+ "syscall"
+ "time"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+
+ hessian "github.com/apache/dubbo-go-hessian2"
+
+ "github.com/dubbogo/gost/log/logger"
+)
+
+var (
+ survivalTimeout = int(3e9)
+)
+
+func init() {
+ config.SetProviderService(&UserProvider{})
+ config.SetProviderService(&UserProviderWithCustomGroupAndVersion{})
+ // ------for hessian2------
+ hessian.RegisterPOJO(&User{})
+}
+
+type User struct {
+ ID string
+ Name string
+ Age int32
+ Time time.Time
+}
+
+type UserProvider struct {
+}
+
+func (u *UserProvider) GetUser(ctx context.Context, req *User) (*User, error) {
+ logger.Infof("req:%#v", req)
+ rsp := User{"A001", "Alex Stocks", 18, time.Now()}
+ logger.Infof("rsp:%#v", rsp)
+ return &rsp, nil
+}
+
+func (u *User) JavaClassName() string {
+ return "org.apache.dubbo.User"
+}
+
+type UserProviderWithCustomGroupAndVersion struct {
+}
+
+func (u *UserProviderWithCustomGroupAndVersion) GetUser(ctx context.Context,
req *User) (*User, error) {
+ logger.Infof("req:%#v", req)
+ rsp := User{"A001", "Alex Stocks from
UserProviderWithCustomGroupAndVersion", 18, time.Now()}
+ logger.Infof("rsp:%#v", rsp)
+ return &rsp, nil
+}
+
+// need to setup environment variable "CONF_PROVIDER_FILE_PATH" to
"conf/server.yml" before run
+func main() {
+ if err := config.Load(); err != nil {
+ panic(err)
+ }
+
+ initSignal()
+}
+
+func initSignal() {
+ signals := make(chan os.Signal, 1)
+ // It is not possible to block SIGKILL or syscall.SIGSTOP
+ signal.Notify(signals, os.Interrupt, syscall.SIGHUP, syscall.SIGQUIT,
syscall.SIGTERM)
+ for {
+ sig := <-signals
+ logger.Infof("get signal %s", sig.String())
+ switch sig {
+ case syscall.SIGHUP:
+ // reload()
+ default:
+ time.AfterFunc(time.Duration(survivalTimeout), func() {
+ logger.Warnf("app exit now by force...")
+ os.Exit(1)
+ })
+
+ // The program exits normally or timeout forcibly exits.
+ fmt.Println("provider app exit now...")
+ return
+ }
+ }
+}
diff --git a/compatibility/polaris/registry/go-server/conf/dubbogo.yml
b/compatibility/polaris/registry/go-server/conf/dubbogo.yml
new file mode 100644
index 00000000..0c0c7f70
--- /dev/null
+++ b/compatibility/polaris/registry/go-server/conf/dubbogo.yml
@@ -0,0 +1,27 @@
+dubbo:
+ application:
+ name: myApp # metadata: application=myApp; name=myApp
+ module: opensource #metadata: module=opensource
+ group: myAppGroup # no metadata record
+ organization: dubbo # metadata: organization=dubbo
+ owner: laurence # metadata: owner=laurence
+ version: myversion # metadata: app.version=myversion
+ environment: pro # metadata: environment=pro
+ registries:
+ polarisMesh:
+ protocol: polaris
+ address: 127.0.0.1:8091
+ namespace: dubbogo
+ registry-type: interface
+ protocols:
+ dubbo:
+ name: dubbo
+ port: 20000
+ provider:
+ services:
+ UserProvider:
+ interface: org.apache.dubbo.UserProvider.Test
+ UserProviderWithCustomGroupAndVersion:
+ interface: org.apache.dubbo.UserProvider.Test2
+ version: myInterfaceVersion # dubbo interface version must be same
with client
+ group: myInterfaceGroup # dubbo interface group must be same with
client
\ No newline at end of file
diff --git a/compatibility/polaris/router/README-zh.md
b/compatibility/polaris/router/README-zh.md
new file mode 100644
index 00000000..be48668d
--- /dev/null
+++ b/compatibility/polaris/router/README-zh.md
@@ -0,0 +1,121 @@
+# Dubbo Go & Polaris Router Example
+
+[English](README.md) | 中文
+
+## 使用服务路由功能
+
+在 dubbogo 中快速体验北极星的服务路由能力
+
+## 北极星服务端安装
+
+[北极星服务端单机版本安装文档](https://polarismesh.cn/docs/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/%E5%8D%95%E6%9C%BA%E7%89%88%E5%AE%89%E8%A3%85/)
+
+[北极星服务端集群版本安装文档](https://polarismesh.cn/docs/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/%E9%9B%86%E7%BE%A4%E7%89%88%E5%AE%89%E8%A3%85/)
+
+## 如何使用
+
+[北极星服务路由使用文档](https://polarismesh.cn/docs/%E5%8C%97%E6%9E%81%E6%98%9F%E6%98%AF%E4%BB%80%E4%B9%88/%E5%8A%9F%E8%83%BD%E7%89%B9%E6%80%A7/%E6%B5%81%E9%87%8F%E7%AE%A1%E7%90%86/#%E5%8A%A8%E6%80%81%E8%B7%AF%E7%94%B1)
+
+### dubbogo.yaml 配置文件
+
+在使用 PolarisMesh 的服务路由能力时,需要先启用 PolarisMesh 在 dubbogo 中的注册发现功能。
+
+```yaml
+dubbo:
+ registries:
+ polarisMesh:
+ protocol: polaris
+ address: ${北极星服务端IP}:8091
+ namespace: ${北极星命名空间信息}
+ token: ${北极星资源鉴权 token} # 如果北极星服务端开启了针对客户端的鉴权,则需要配置该参数
+ provider:
+ services:
+ UserProvider:
+ interface: org.apache.dubbo.UserProvider.Test
+```
+
+### 如何配置服务路由参数
+
+dubbogo 中的 PolarisMesh PriorityRouter 扩展点实现,能够根据用户配置的服务路由规则,自动的从当前 RPC
调用上下文以及请求信息中识别出需要参与服务路由的请求标签信息
+
+
+
+
+
+- 请求匹配规则为 **请求参数(QUERY)**
+ - 标签来源: RPC 调用中方法的入参,即 Invoaction.Arguments()
+ - 标签键规则
+ - 方法仅有一个入参: param.$.${fieldName}, **param.** 为固定前缀,后面的表达式为标准的 JSONPath
expressions,[参考文档](https://goessner.net/articles/JsonPath/)
+ - 方法有多个参数: param[${index}].$.${fieldName}, **param[${index}].**
为固定前缀,${index} 代表是方法入参中的第几个参数,下标起始位置从 0 开始;后面的表达式为标准的 JSONPath
expressions,[参考文档](https://goessner.net/articles/JsonPath/)
+- 请求匹配规则为 **请求头(HEADER)**:
+ - 标签来源: RPC 调用的额外标签信息,即 Invoaction.Attachments()
+
+### 运行服务提供者
+
+分别进入 server-prod、server-pre、server-dev 的 cmd 目录,执行以下命令
+
+```
+ export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yaml"
+ go run .
+```
+
+当看到以下日志时即表示 server 端启动成功
+
+```log
+INFO dubbo/dubbo_protocol.go:84 [DUBBO Protocol] Export service:
+```
+
+
+### 运行服务调用者
+
+进入 go-client 的 cmd 目录,执行以下命令
+
+
+```
+export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+export uid=user-1
+go run .
+```
+
+当看到以下日志时即表示 go-client 成功发现 go-server 并发起了 RPC 调用
+
+```log
+INFO cmd/main.go:75 response: &{A001 Alex Stocks 18 2022-11-19
12:52:38.092 +0800 CST}
+```
+
+分别执行以下命令
+
+```bash
+export uid=
+go run .
+
+export uid=user-1
+go run .
+
+export uid=user-2
+```
+
+当看到以下日志时即表示在 PolarisMesh 配置的路由策略已生效
+
+```log
+# export uid=
+2022-11-26T13:39:31.637+0800 INFO cmd/main.go:78 response: &{A001
[Prod] Alex Stocks 18 2022-11-26 13:39:31.637 +0800 CST}
+2022-11-26T13:39:31.842+0800 INFO cmd/main.go:78 response: &{A001
[Prod] Alex Stocks 18 2022-11-26 13:39:31.841 +0800 CST}
+2022-11-26T13:39:32.043+0800 INFO cmd/main.go:78 response: &{A001
[Prod] Alex Stocks 18 2022-11-26 13:39:32.043 +0800 CST}
+2022-11-26T13:39:32.247+0800 INFO cmd/main.go:78 response: &{A001
[Prod] Alex Stocks 18 2022-11-26 13:39:32.247 +0800 CST}
+2022-11-26T13:39:32.452+0800 INFO cmd/main.go:78 response: &{A001
[Prod] Alex Stocks 18 2022-11-26 13:39:32.452 +0800 CST}
+
+# export uid=user-1
+2022-11-26T13:39:51.053+0800 INFO cmd/main.go:78 response: &{A001 [Pre]
Alex Stocks 18 2022-11-26 13:39:51.053 +0800 CST}
+2022-11-26T13:39:51.257+0800 INFO cmd/main.go:78 response: &{A001 [Pre]
Alex Stocks 18 2022-11-26 13:39:51.257 +0800 CST}
+2022-11-26T13:39:51.459+0800 INFO cmd/main.go:78 response: &{A001 [Pre]
Alex Stocks 18 2022-11-26 13:39:51.459 +0800 CST}
+2022-11-26T13:39:51.662+0800 INFO cmd/main.go:78 response: &{A001 [Pre]
Alex Stocks 18 2022-11-26 13:39:51.662 +0800 CST}
+2022-11-26T13:39:51.866+0800 INFO cmd/main.go:78 response: &{A001 [Pre]
Alex Stocks 18 2022-11-26 13:39:51.866 +0800 CST}
+
+# export uid=user-2
+2022-11-26T13:42:39.351+0800 INFO cmd/main.go:78 response: &{A001 [Dev]
Alex Stocks 18 2022-11-26 13:42:39.351 +0800 CST}
+2022-11-26T13:42:39.555+0800 INFO cmd/main.go:78 response: &{A001 [Dev]
Alex Stocks 18 2022-11-26 13:42:39.555 +0800 CST}
+2022-11-26T13:42:39.760+0800 INFO cmd/main.go:78 response: &{A001 [Dev]
Alex Stocks 18 2022-11-26 13:42:39.76 +0800 CST}
+2022-11-26T13:42:39.962+0800 INFO cmd/main.go:78 response: &{A001 [Dev]
Alex Stocks 18 2022-11-26 13:42:39.961 +0800 CST}
+2022-11-26T13:42:40.165+0800 INFO cmd/main.go:78 response: &{A001 [Dev]
Alex Stocks 18 2022-11-26 13:42:40.165 +0800 CST}
+```
diff --git a/compatibility/polaris/router/README.md
b/compatibility/polaris/router/README.md
new file mode 100644
index 00000000..a80804d8
--- /dev/null
+++ b/compatibility/polaris/router/README.md
@@ -0,0 +1,121 @@
+# Dubbo Go & Polaris Router Example
+
+English | [中文](README-zh.md)
+
+## Using the service routing function
+
+Quickly experience Polaris' service routing capabilities in dubbogo
+
+## Polaris server installation
+
+[Polaris Server Standalone Version Installation
Documentation](https://polarismesh.cn/docs/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/%E5%8D%95%E6%9C%BA%E7%89%88%E5%AE%89%E8%A3%85/)
+
+[Polaris Server Cluster Version Installation
Documentation](https://polarismesh.cn/docs/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/%E9%9B%86%E7%BE%A4%E7%89%88%E5%AE%89%E8%A3%85/)
+
+## how to use
+
+[Polaris Service Routing Usage
Document](https://polarismesh.cn/docs/%E5%8C%97%E6%9E%81%E6%98%9F%E6%98%AF%E4%BB%80%E4%B9%88/%E5%8A%9F%E8%83%BD%E7%89%B9%E6%80%A7/%E6%B5%81%E9%87%8F%E7%AE%A1%E7%90%86/#%E5%8A%A8%E6%80%81%E8%B7%AF%E7%94%B1)
+
+### dubbogo.yaml configuration file
+
+When using PolarisMesh's service route capability, you need to enable
PolarisMesh's registration discovery function in dubbogo firstly.
+
+````yaml
+dubbo:
+ registries:
+ polarisMesh:
+ protocol: polaris
+ address: ${Polaris server IP}:8091
+ namespace: ${Polaris namespace information}
+ token: ${Polaris resource authentication token} # If the Polaris server
has enabled authentication for the client, you need to configure this parameter
+ provider:
+ services:
+ UserProvider:
+ interface: org.apache.dubbo.UserProvider.Test
+````
+
+### How to configure service routing parameters
+
+The implementation of the PolarisMesh PriorityRouter extension point in
dubbogo can automatically identify the request label information that needs to
participate in service routing from the current RPC call context and request
information according to the service route rules configured by the user.
+
+
+
+
+
+- The request matching rule is **Request parameter(QUERY)**
+ - Tag source: the input parameter of the method in the RPC call, namely
Invoaction.Arguments()
+ - Tag key rules
+ - The method has only one input parameter: param.$.${fieldName},
**param.** is a fixed prefix, the following expressions are standard JSONPath
expressions, [reference document](https://goessner.net/ articles/JsonPath/)
+ - The method has multiple parameters: param[${index}].$.${fieldName},
**param[${index}].** is a fixed prefix, ${index} represents the first parameter
in the method parameter Several parameters, the starting position of the
subscript starts from 0; the following expressions are standard JSONPath
expressions, [reference document](https://goessner.net/articles/JsonPath/)
+- The request matching rule is **request header (HEADER)**:
+ - Tag source: Additional tag information for RPC calls, i.e.
Invoaction.Attachments()
+
+### Running the service provider
+
+Enter the cmd directory of server-prod, server-pre, and server-dev
respectively, and execute the following commands
+
+````
+ export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yaml"
+ go run .
+````
+
+When you see the following log, it means that the server side started
successfully
+
+````log
+INFO dubbo/dubbo_protocol.go:84 [DUBBO Protocol] Export service:
+````
+
+
+### Running the service caller
+
+Enter the cmd directory of go-client and execute the following command
+
+
+````
+export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+export uid=user-1
+go run .
+````
+
+When you see the following log, it means that go-client successfully
discovered go-server and made an RPC call
+
+````log
+INFO cmd/main.go:75 response: &{A001 Alex Stocks 18 2022-11-19 12:52:38.092
+0800 CST}
+````
+
+Execute the following commands respectively
+
+```bash
+export uid=
+go run .
+
+export uid=user-1
+go run .
+
+export uid=user-2
+````
+
+When you see the following log, it means that the routing policy configured in
PolarisMesh has taken effect
+
+```log
+# export uid=
+2022-11-26T13:39:31.637+0800 INFO cmd/main.go:78 response: &{A001
[Prod] Alex Stocks 18 2022-11-26 13:39:31.637 +0800 CST}
+2022-11-26T13:39:31.842+0800 INFO cmd/main.go:78 response: &{A001
[Prod] Alex Stocks 18 2022-11-26 13:39:31.841 +0800 CST}
+2022-11-26T13:39:32.043+0800 INFO cmd/main.go:78 response: &{A001
[Prod] Alex Stocks 18 2022-11-26 13:39:32.043 +0800 CST}
+2022-11-26T13:39:32.247+0800 INFO cmd/main.go:78 response: &{A001
[Prod] Alex Stocks 18 2022-11-26 13:39:32.247 +0800 CST}
+2022-11-26T13:39:32.452+0800 INFO cmd/main.go:78 response: &{A001
[Prod] Alex Stocks 18 2022-11-26 13:39:32.452 +0800 CST}
+
+# export uid=user-1
+2022-11-26T13:39:51.053+0800 INFO cmd/main.go:78 response: &{A001 [Pre]
Alex Stocks 18 2022-11-26 13:39:51.053 +0800 CST}
+2022-11-26T13:39:51.257+0800 INFO cmd/main.go:78 response: &{A001 [Pre]
Alex Stocks 18 2022-11-26 13:39:51.257 +0800 CST}
+2022-11-26T13:39:51.459+0800 INFO cmd/main.go:78 response: &{A001 [Pre]
Alex Stocks 18 2022-11-26 13:39:51.459 +0800 CST}
+2022-11-26T13:39:51.662+0800 INFO cmd/main.go:78 response: &{A001 [Pre]
Alex Stocks 18 2022-11-26 13:39:51.662 +0800 CST}
+2022-11-26T13:39:51.866+0800 INFO cmd/main.go:78 response: &{A001 [Pre]
Alex Stocks 18 2022-11-26 13:39:51.866 +0800 CST}
+
+# export uid=user-2
+2022-11-26T13:42:39.351+0800 INFO cmd/main.go:78 response: &{A001 [Dev]
Alex Stocks 18 2022-11-26 13:42:39.351 +0800 CST}
+2022-11-26T13:42:39.555+0800 INFO cmd/main.go:78 response: &{A001 [Dev]
Alex Stocks 18 2022-11-26 13:42:39.555 +0800 CST}
+2022-11-26T13:42:39.760+0800 INFO cmd/main.go:78 response: &{A001 [Dev]
Alex Stocks 18 2022-11-26 13:42:39.76 +0800 CST}
+2022-11-26T13:42:39.962+0800 INFO cmd/main.go:78 response: &{A001 [Dev]
Alex Stocks 18 2022-11-26 13:42:39.961 +0800 CST}
+2022-11-26T13:42:40.165+0800 INFO cmd/main.go:78 response: &{A001 [Dev]
Alex Stocks 18 2022-11-26 13:42:40.165 +0800 CST}
+```
diff --git a/compatibility/polaris/router/go-client/cmd/main.go
b/compatibility/polaris/router/go-client/cmd/main.go
new file mode 100644
index 00000000..1e4f6b53
--- /dev/null
+++ b/compatibility/polaris/router/go-client/cmd/main.go
@@ -0,0 +1,81 @@
+/*
+ * 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"
+ "os"
+ "time"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/common/constant"
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+
+ hessian "github.com/apache/dubbo-go-hessian2"
+
+ "github.com/dubbogo/gost/log/logger"
+)
+
+type UserProviderWithCustomGroupAndVersion struct {
+ GetUser func(ctx context.Context, req *User) (rsp *User, err error)
+}
+
+type UserProvider struct {
+ GetUser func(ctx context.Context, req *User) (rsp *User, err error)
+}
+
+type User struct {
+ ID string
+ Name string
+ Age int32
+ Time time.Time
+}
+
+func (u *User) JavaClassName() string {
+ return "org.apache.dubbo.User"
+}
+
+func main() {
+ var userProvider = &UserProvider{}
+ var userProviderWithCustomRegistryGroupAndVersion =
&UserProviderWithCustomGroupAndVersion{}
+ config.SetConsumerService(userProvider)
+ config.SetConsumerService(userProviderWithCustomRegistryGroupAndVersion)
+ hessian.RegisterPOJO(&User{})
+ err := config.Load()
+ if err != nil {
+ panic(err)
+ }
+
+ logger.Infof("\n\n\nstart to test dubbo")
+
+ uid := os.Getenv("uid")
+ atta := make(map[string]interface{})
+ atta["uid"] = uid
+ reqContext := context.WithValue(context.Background(),
constant.DubboCtxKey("attachment"), atta)
+
+ for i := 0; i < 5; i++ {
+ time.Sleep(200 * time.Millisecond)
+ user, err := userProvider.GetUser(reqContext, &User{Name:
"Alex001"})
+ if err != nil {
+ panic(err)
+ }
+ logger.Infof("response: %v\n", user)
+ }
+}
diff --git a/compatibility/polaris/router/go-client/conf/dubbogo.yaml
b/compatibility/polaris/router/go-client/conf/dubbogo.yaml
new file mode 100644
index 00000000..b41630c6
--- /dev/null
+++ b/compatibility/polaris/router/go-client/conf/dubbogo.yaml
@@ -0,0 +1,25 @@
+
+dubbo:
+ application:
+ name: myApp # metadata: application=myApp; name=myApp
+ module: opensource #metadata: module=opensource
+ group: myAppGroup # no metadata record
+ organization: dubbo # metadata: organization=dubbo
+ owner: laurence # metadata: owner=laurence
+ version: myversion # metadata: app.version=myversion
+ environment: pro # metadata: environment=pro
+ registries:
+ polarisMesh:
+ protocol: polaris
+ address: 127.0.0.1:8091
+ namespace: dubbogo
+ registry-type: interface
+ consumer:
+ references:
+ UserProvider:
+ protocol: dubbo
+ interface: org.apache.dubbo.UserProvider.Test
+ UserProviderWithCustomGroupAndVersion:
+ protocol: dubbo
+ interface: org.apache.dubbo.UserProvider.Test2
+ version: myInterfaceVersion # dubbo interface version must be same
with server
diff --git a/compatibility/polaris/router/go-server/server-dev/cmd/server.go
b/compatibility/polaris/router/go-server/server-dev/cmd/server.go
new file mode 100644
index 00000000..71eab8ac
--- /dev/null
+++ b/compatibility/polaris/router/go-server/server-dev/cmd/server.go
@@ -0,0 +1,111 @@
+/*
+ * 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"
+ "fmt"
+ "os"
+ "os/signal"
+ "syscall"
+ "time"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/filter/tps/strategy"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+
+ hessian "github.com/apache/dubbo-go-hessian2"
+
+ "github.com/dubbogo/gost/log/logger"
+)
+
+var (
+ survivalTimeout = int(3e9)
+)
+
+func init() {
+ config.SetProviderService(&UserProvider{})
+ config.SetProviderService(&UserProviderWithCustomGroupAndVersion{})
+ // ------for hessian2------
+ hessian.RegisterPOJO(&User{})
+}
+
+type User struct {
+ ID string
+ Name string
+ Age int32
+ Time time.Time
+}
+
+type UserProvider struct {
+}
+
+func (u *UserProvider) GetUser(ctx context.Context, req *User) (*User, error) {
+ logger.Infof("req:%#v", req)
+ rsp := User{"A001", "[Dev] Alex Stocks", 18, time.Now()}
+ logger.Infof("rsp:%#v", rsp)
+ return &rsp, nil
+}
+
+func (u *User) JavaClassName() string {
+ return "org.apache.dubbo.User"
+}
+
+type UserProviderWithCustomGroupAndVersion struct {
+}
+
+func (u *UserProviderWithCustomGroupAndVersion) GetUser(ctx context.Context,
req *User) (*User, error) {
+ logger.Infof("req:%#v", req)
+ rsp := User{"A001", "[Dev] Alex Stocks", 18, time.Now()}
+ logger.Infof("rsp:%#v", rsp)
+ return &rsp, nil
+}
+
+// need to setup environment variable "CONF_PROVIDER_FILE_PATH" to
"conf/server.yml" before run
+func main() {
+ if err := config.Load(); err != nil {
+ panic(err)
+ }
+
+ initSignal()
+}
+
+func initSignal() {
+ signals := make(chan os.Signal, 1)
+ // It is not possible to block SIGKILL or syscall.SIGSTOP
+ signal.Notify(signals, os.Interrupt, syscall.SIGHUP, syscall.SIGQUIT,
syscall.SIGTERM)
+ for {
+ sig := <-signals
+ logger.Infof("get signal %s", sig.String())
+ switch sig {
+ case syscall.SIGHUP:
+ // reload()
+ default:
+ time.AfterFunc(time.Duration(survivalTimeout), func() {
+ logger.Warnf("app exit now by force...")
+ os.Exit(1)
+ })
+
+ // The program exits normally or timeout forcibly exits.
+ fmt.Println("provider app exit now...")
+ return
+ }
+ }
+}
diff --git
a/compatibility/polaris/router/go-server/server-dev/conf/dubbogo.yaml
b/compatibility/polaris/router/go-server/server-dev/conf/dubbogo.yaml
new file mode 100644
index 00000000..557ea4c4
--- /dev/null
+++ b/compatibility/polaris/router/go-server/server-dev/conf/dubbogo.yaml
@@ -0,0 +1,28 @@
+dubbo:
+ application:
+ name: myApp # metadata: application=myApp; name=myApp
+ module: opensource #metadata: module=opensource
+ group: myAppGroup # no metadata record
+ organization: dubbo # metadata: organization=dubbo
+ owner: laurence # metadata: owner=laurence
+ version: myversion # metadata: app.version=myversion
+ environment: dev # metadata: environment=pro
+ registries:
+ polarisMesh:
+ protocol: polaris
+ address: 127.0.0.1:8091
+ namespace: dubbogo
+ registry-type: interface
+ protocols:
+ dubbo:
+ name: dubbo
+ port: 20000
+ provider:
+ services:
+ UserProvider:
+ interface: org.apache.dubbo.UserProvider.Test
+ tps.limiter: polaris-limit # the Limiter that judge if the TPS overs
the threshold, such as method-service or default
+ UserProviderWithCustomGroupAndVersion:
+ interface: org.apache.dubbo.UserProvider.Test2
+ version: myInterfaceVersion # dubbo interface version must be same
with client
+ group: myInterfaceGroup # dubbo interface group must be same with
client
diff --git a/compatibility/polaris/router/go-server/server-pre/cmd/server.go
b/compatibility/polaris/router/go-server/server-pre/cmd/server.go
new file mode 100644
index 00000000..46ef833e
--- /dev/null
+++ b/compatibility/polaris/router/go-server/server-pre/cmd/server.go
@@ -0,0 +1,111 @@
+/*
+ * 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"
+ "fmt"
+ "os"
+ "os/signal"
+ "syscall"
+ "time"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/filter/tps/strategy"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+
+ hessian "github.com/apache/dubbo-go-hessian2"
+
+ "github.com/dubbogo/gost/log/logger"
+)
+
+var (
+ survivalTimeout = int(3e9)
+)
+
+func init() {
+ config.SetProviderService(&UserProvider{})
+ config.SetProviderService(&UserProviderWithCustomGroupAndVersion{})
+ // ------for hessian2------
+ hessian.RegisterPOJO(&User{})
+}
+
+type User struct {
+ ID string
+ Name string
+ Age int32
+ Time time.Time
+}
+
+type UserProvider struct {
+}
+
+func (u *UserProvider) GetUser(ctx context.Context, req *User) (*User, error) {
+ logger.Infof("req:%#v", req)
+ rsp := User{"A001", "[Pre] Alex Stocks", 18, time.Now()}
+ logger.Infof("rsp:%#v", rsp)
+ return &rsp, nil
+}
+
+func (u *User) JavaClassName() string {
+ return "org.apache.dubbo.User"
+}
+
+type UserProviderWithCustomGroupAndVersion struct {
+}
+
+func (u *UserProviderWithCustomGroupAndVersion) GetUser(ctx context.Context,
req *User) (*User, error) {
+ logger.Infof("req:%#v", req)
+ rsp := User{"A001", "[Pre] Alex Stocks", 18, time.Now()}
+ logger.Infof("rsp:%#v", rsp)
+ return &rsp, nil
+}
+
+// need to setup environment variable "CONF_PROVIDER_FILE_PATH" to
"conf/server.yml" before run
+func main() {
+ if err := config.Load(); err != nil {
+ panic(err)
+ }
+
+ initSignal()
+}
+
+func initSignal() {
+ signals := make(chan os.Signal, 1)
+ // It is not possible to block SIGKILL or syscall.SIGSTOP
+ signal.Notify(signals, os.Interrupt, syscall.SIGHUP, syscall.SIGQUIT,
syscall.SIGTERM)
+ for {
+ sig := <-signals
+ logger.Infof("get signal %s", sig.String())
+ switch sig {
+ case syscall.SIGHUP:
+ // reload()
+ default:
+ time.AfterFunc(time.Duration(survivalTimeout), func() {
+ logger.Warnf("app exit now by force...")
+ os.Exit(1)
+ })
+
+ // The program exits normally or timeout forcibly exits.
+ fmt.Println("provider app exit now...")
+ return
+ }
+ }
+}
diff --git
a/compatibility/polaris/router/go-server/server-pre/conf/dubbogo.yaml
b/compatibility/polaris/router/go-server/server-pre/conf/dubbogo.yaml
new file mode 100644
index 00000000..1ef24dfc
--- /dev/null
+++ b/compatibility/polaris/router/go-server/server-pre/conf/dubbogo.yaml
@@ -0,0 +1,28 @@
+dubbo:
+ application:
+ name: myApp # metadata: application=myApp; name=myApp
+ module: opensource #metadata: module=opensource
+ group: myAppGroup # no metadata record
+ organization: dubbo # metadata: organization=dubbo
+ owner: laurence # metadata: owner=laurence
+ version: myversion # metadata: app.version=myversion
+ environment: pre # metadata: environment=pro
+ registries:
+ polarisMesh:
+ protocol: polaris
+ address: 127.0.0.1:8091
+ namespace: dubbogo
+ registry-type: interface
+ protocols:
+ dubbo:
+ name: dubbo
+ port: 21000
+ provider:
+ services:
+ UserProvider:
+ interface: org.apache.dubbo.UserProvider.Test
+ tps.limiter: polaris-limit # the Limiter that judge if the TPS overs
the threshold, such as method-service or default
+ UserProviderWithCustomGroupAndVersion:
+ interface: org.apache.dubbo.UserProvider.Test2
+ version: myInterfaceVersion # dubbo interface version must be same
with client
+ group: myInterfaceGroup # dubbo interface group must be same with
client
diff --git a/compatibility/polaris/router/go-server/server-prod/cmd/server.go
b/compatibility/polaris/router/go-server/server-prod/cmd/server.go
new file mode 100644
index 00000000..56dc89a0
--- /dev/null
+++ b/compatibility/polaris/router/go-server/server-prod/cmd/server.go
@@ -0,0 +1,111 @@
+/*
+ * 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"
+ "fmt"
+ "os"
+ "os/signal"
+ "syscall"
+ "time"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/filter/tps/strategy"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+
+ hessian "github.com/apache/dubbo-go-hessian2"
+
+ "github.com/dubbogo/gost/log/logger"
+)
+
+var (
+ survivalTimeout = int(3e9)
+)
+
+func init() {
+ config.SetProviderService(&UserProvider{})
+ config.SetProviderService(&UserProviderWithCustomGroupAndVersion{})
+ // ------for hessian2------
+ hessian.RegisterPOJO(&User{})
+}
+
+type User struct {
+ ID string
+ Name string
+ Age int32
+ Time time.Time
+}
+
+type UserProvider struct {
+}
+
+func (u *UserProvider) GetUser(ctx context.Context, req *User) (*User, error) {
+ logger.Infof("req:%#v", req)
+ rsp := User{"A001", "[Prod] Alex Stocks", 18, time.Now()}
+ logger.Infof("rsp:%#v", rsp)
+ return &rsp, nil
+}
+
+func (u *User) JavaClassName() string {
+ return "org.apache.dubbo.User"
+}
+
+type UserProviderWithCustomGroupAndVersion struct {
+}
+
+func (u *UserProviderWithCustomGroupAndVersion) GetUser(ctx context.Context,
req *User) (*User, error) {
+ logger.Infof("req:%#v", req)
+ rsp := User{"A001", "[Prod] Alex Stocks", 18, time.Now()}
+ logger.Infof("rsp:%#v", rsp)
+ return &rsp, nil
+}
+
+// need to setup environment variable "CONF_PROVIDER_FILE_PATH" to
"conf/server.yml" before run
+func main() {
+ if err := config.Load(); err != nil {
+ panic(err)
+ }
+
+ initSignal()
+}
+
+func initSignal() {
+ signals := make(chan os.Signal, 1)
+ // It is not possible to block SIGKILL or syscall.SIGSTOP
+ signal.Notify(signals, os.Interrupt, syscall.SIGHUP, syscall.SIGQUIT,
syscall.SIGTERM)
+ for {
+ sig := <-signals
+ logger.Infof("get signal %s", sig.String())
+ switch sig {
+ case syscall.SIGHUP:
+ // reload()
+ default:
+ time.AfterFunc(time.Duration(survivalTimeout), func() {
+ logger.Warnf("app exit now by force...")
+ os.Exit(1)
+ })
+
+ // The program exits normally or timeout forcibly exits.
+ fmt.Println("provider app exit now...")
+ return
+ }
+ }
+}
diff --git
a/compatibility/polaris/router/go-server/server-prod/conf/dubbogo.yaml
b/compatibility/polaris/router/go-server/server-prod/conf/dubbogo.yaml
new file mode 100644
index 00000000..cd623867
--- /dev/null
+++ b/compatibility/polaris/router/go-server/server-prod/conf/dubbogo.yaml
@@ -0,0 +1,28 @@
+dubbo:
+ application:
+ name: myApp # metadata: application=myApp; name=myApp
+ module: opensource #metadata: module=opensource
+ group: myAppGroup # no metadata record
+ organization: dubbo # metadata: organization=dubbo
+ owner: laurence # metadata: owner=laurence
+ version: myversion # metadata: app.version=myversion
+ environment: prod # metadata: environment=pro
+ registries:
+ polarisMesh:
+ protocol: polaris
+ address: 127.0.0.1:8091
+ namespace: dubbogo
+ registry-type: interface
+ protocols:
+ dubbo:
+ name: dubbo
+ port: 22000
+ provider:
+ services:
+ UserProvider:
+ interface: org.apache.dubbo.UserProvider.Test
+ tps.limiter: polaris-limit # the Limiter that judge if the TPS overs
the threshold, such as method-service or default
+ UserProviderWithCustomGroupAndVersion:
+ interface: org.apache.dubbo.UserProvider.Test2
+ version: myInterfaceVersion # dubbo interface version must be same
with client
+ group: myInterfaceGroup # dubbo interface group must be same with
client
diff --git a/compatibility/polaris/router/images/dubbogo-route-rule-dev.png
b/compatibility/polaris/router/images/dubbogo-route-rule-dev.png
new file mode 100644
index 00000000..b61ed0eb
Binary files /dev/null and
b/compatibility/polaris/router/images/dubbogo-route-rule-dev.png differ
diff --git a/compatibility/polaris/router/images/dubbogo-route-rule-pre.png
b/compatibility/polaris/router/images/dubbogo-route-rule-pre.png
new file mode 100644
index 00000000..61eb8977
Binary files /dev/null and
b/compatibility/polaris/router/images/dubbogo-route-rule-pre.png differ
diff --git a/compatibility/polaris/router/images/dubbogo-route-rule-prod.png
b/compatibility/polaris/router/images/dubbogo-route-rule-prod.png
new file mode 100644
index 00000000..0fd28f07
Binary files /dev/null and
b/compatibility/polaris/router/images/dubbogo-route-rule-prod.png differ
diff --git
a/integrate_test/compatibility/config-api/rpc/triple/tests/integration/main_test.go
b/integrate_test/compatibility/config-api/rpc/triple/tests/integration/main_test.go
index 0ca9cbc4..818b0e6b 100644
---
a/integrate_test/compatibility/config-api/rpc/triple/tests/integration/main_test.go
+++
b/integrate_test/compatibility/config-api/rpc/triple/tests/integration/main_test.go
@@ -48,4 +48,5 @@ func TestMain(m *testing.M) {
panic(err)
}
os.Exit(m.Run())
+
}
diff --git
a/integrate_test/compatibility/config-api/rpc/triple/tests/integration/main_test.go
b/integrate_test/compatibility/polaris/limit/tests/integration/limit_test.go
similarity index 55%
copy from
integrate_test/compatibility/config-api/rpc/triple/tests/integration/main_test.go
copy to
integrate_test/compatibility/polaris/limit/tests/integration/limit_test.go
index 0ca9cbc4..7c68bd8f 100644
---
a/integrate_test/compatibility/config-api/rpc/triple/tests/integration/main_test.go
+++ b/integrate_test/compatibility/polaris/limit/tests/integration/limit_test.go
@@ -18,34 +18,28 @@
package integration
import (
- "os"
+ "context"
"testing"
+ "time"
)
import (
- "dubbo.apache.org/dubbo-go/v3/config"
- _ "dubbo.apache.org/dubbo-go/v3/imports"
+ "github.com/stretchr/testify/assert"
)
-import (
- "github.com/apache/dubbo-go-samples/compatibility/api"
-)
-
-var greeterProvider = new(api.GreeterClientImpl)
+func TestPolarisLimit(t *testing.T) {
-func TestMain(m *testing.M) {
- config.SetConsumerService(greeterProvider)
- rootConfig := config.NewRootConfigBuilder().
- SetConsumer(config.NewConsumerConfigBuilder().
- AddReference("GreeterClientImpl",
config.NewReferenceConfigBuilder().
- SetProtocol("tri").
- Build()).
- Build()).
- AddRegistry("zkRegistryKey",
config.NewRegistryConfigWithProtocolDefaultPort("zookeeper")).
- Build()
-
- if err := config.Load(config.WithRootConfig(rootConfig)); err != nil {
- panic(err)
+ var successCount, failCount int64
+ for i := 0; i < 10; i++ {
+ time.Sleep(50 * time.Millisecond)
+ _, err := userProvider.GetUser(context.TODO(), &User{Name:
"Alex03"})
+ if err != nil {
+ failCount++
+ } else {
+ successCount++
+ }
}
- os.Exit(m.Run())
+ //current limiting effect
+ assert.Equal(t, true, failCount > 0)
+
}
diff --git
a/integrate_test/compatibility/config-api/rpc/triple/tests/integration/main_test.go
b/integrate_test/compatibility/polaris/limit/tests/integration/main_test.go
similarity index 56%
copy from
integrate_test/compatibility/config-api/rpc/triple/tests/integration/main_test.go
copy to
integrate_test/compatibility/polaris/limit/tests/integration/main_test.go
index 0ca9cbc4..5db1c648 100644
---
a/integrate_test/compatibility/config-api/rpc/triple/tests/integration/main_test.go
+++ b/integrate_test/compatibility/polaris/limit/tests/integration/main_test.go
@@ -18,34 +18,48 @@
package integration
import (
- "os"
+ "context"
"testing"
+ "time"
)
import (
"dubbo.apache.org/dubbo-go/v3/config"
_ "dubbo.apache.org/dubbo-go/v3/imports"
-)
-import (
- "github.com/apache/dubbo-go-samples/compatibility/api"
+ hessian "github.com/apache/dubbo-go-hessian2"
)
-var greeterProvider = new(api.GreeterClientImpl)
+type UserProviderWithCustomGroupAndVersion struct {
+ GetUser func(ctx context.Context, req *User) (rsp *User, err error)
+}
+
+type UserProvider struct {
+ GetUser func(ctx context.Context, req *User) (rsp *User, err error)
+}
+
+type User struct {
+ ID string
+ Name string
+ Age int32
+ Time time.Time
+}
+
+func (u *User) JavaClassName() string {
+ return "org.apache.dubbo.User"
+}
+
+var userProvider = &UserProvider{}
+var userProviderWithCustomRegistryGroupAndVersion =
&UserProviderWithCustomGroupAndVersion{}
func TestMain(m *testing.M) {
- config.SetConsumerService(greeterProvider)
- rootConfig := config.NewRootConfigBuilder().
- SetConsumer(config.NewConsumerConfigBuilder().
- AddReference("GreeterClientImpl",
config.NewReferenceConfigBuilder().
- SetProtocol("tri").
- Build()).
- Build()).
- AddRegistry("zkRegistryKey",
config.NewRegistryConfigWithProtocolDefaultPort("zookeeper")).
- Build()
-
- if err := config.Load(config.WithRootConfig(rootConfig)); err != nil {
+
+ config.SetConsumerService(userProvider)
+ config.SetConsumerService(userProviderWithCustomRegistryGroupAndVersion)
+ hessian.RegisterPOJO(&User{})
+ err := config.Load()
+ if err != nil {
panic(err)
}
- os.Exit(m.Run())
+
}
diff --git
a/integrate_test/compatibility/config-api/rpc/triple/tests/integration/main_test.go
b/integrate_test/compatibility/polaris/registry/tests/integration/main_test.go
similarity index 56%
copy from
integrate_test/compatibility/config-api/rpc/triple/tests/integration/main_test.go
copy to
integrate_test/compatibility/polaris/registry/tests/integration/main_test.go
index 0ca9cbc4..5db1c648 100644
---
a/integrate_test/compatibility/config-api/rpc/triple/tests/integration/main_test.go
+++
b/integrate_test/compatibility/polaris/registry/tests/integration/main_test.go
@@ -18,34 +18,48 @@
package integration
import (
- "os"
+ "context"
"testing"
+ "time"
)
import (
"dubbo.apache.org/dubbo-go/v3/config"
_ "dubbo.apache.org/dubbo-go/v3/imports"
-)
-import (
- "github.com/apache/dubbo-go-samples/compatibility/api"
+ hessian "github.com/apache/dubbo-go-hessian2"
)
-var greeterProvider = new(api.GreeterClientImpl)
+type UserProviderWithCustomGroupAndVersion struct {
+ GetUser func(ctx context.Context, req *User) (rsp *User, err error)
+}
+
+type UserProvider struct {
+ GetUser func(ctx context.Context, req *User) (rsp *User, err error)
+}
+
+type User struct {
+ ID string
+ Name string
+ Age int32
+ Time time.Time
+}
+
+func (u *User) JavaClassName() string {
+ return "org.apache.dubbo.User"
+}
+
+var userProvider = &UserProvider{}
+var userProviderWithCustomRegistryGroupAndVersion =
&UserProviderWithCustomGroupAndVersion{}
func TestMain(m *testing.M) {
- config.SetConsumerService(greeterProvider)
- rootConfig := config.NewRootConfigBuilder().
- SetConsumer(config.NewConsumerConfigBuilder().
- AddReference("GreeterClientImpl",
config.NewReferenceConfigBuilder().
- SetProtocol("tri").
- Build()).
- Build()).
- AddRegistry("zkRegistryKey",
config.NewRegistryConfigWithProtocolDefaultPort("zookeeper")).
- Build()
-
- if err := config.Load(config.WithRootConfig(rootConfig)); err != nil {
+
+ config.SetConsumerService(userProvider)
+ config.SetConsumerService(userProviderWithCustomRegistryGroupAndVersion)
+ hessian.RegisterPOJO(&User{})
+ err := config.Load()
+ if err != nil {
panic(err)
}
- os.Exit(m.Run())
+
}
diff --git
a/integrate_test/compatibility/config-api/rpc/triple/tests/integration/main_test.go
b/integrate_test/compatibility/polaris/registry/tests/integration/registry_test.go
similarity index 54%
copy from
integrate_test/compatibility/config-api/rpc/triple/tests/integration/main_test.go
copy to
integrate_test/compatibility/polaris/registry/tests/integration/registry_test.go
index 0ca9cbc4..76251f2c 100644
---
a/integrate_test/compatibility/config-api/rpc/triple/tests/integration/main_test.go
+++
b/integrate_test/compatibility/polaris/registry/tests/integration/registry_test.go
@@ -18,34 +18,24 @@
package integration
import (
- "os"
+ "context"
"testing"
)
import (
- "dubbo.apache.org/dubbo-go/v3/config"
- _ "dubbo.apache.org/dubbo-go/v3/imports"
+ "github.com/stretchr/testify/assert"
)
-import (
- "github.com/apache/dubbo-go-samples/compatibility/api"
-)
-
-var greeterProvider = new(api.GreeterClientImpl)
-
-func TestMain(m *testing.M) {
- config.SetConsumerService(greeterProvider)
- rootConfig := config.NewRootConfigBuilder().
- SetConsumer(config.NewConsumerConfigBuilder().
- AddReference("GreeterClientImpl",
config.NewReferenceConfigBuilder().
- SetProtocol("tri").
- Build()).
- Build()).
- AddRegistry("zkRegistryKey",
config.NewRegistryConfigWithProtocolDefaultPort("zookeeper")).
- Build()
+func TestPolarisRegistry(t *testing.T) {
+ user, err := userProvider.GetUser(context.TODO(), &User{Name:
"Alex001"})
+ assert.Nil(t, err)
+ assert.NotNil(t, user)
+ assert.Equal(t, user.ID, "A001")
+ assert.Equal(t, user.Name, "Alex Stocks")
+ assert.Equal(t, user.Age, 18)
- if err := config.Load(config.WithRootConfig(rootConfig)); err != nil {
- panic(err)
- }
- os.Exit(m.Run())
+ user, err =
userProviderWithCustomRegistryGroupAndVersion.GetUser(context.TODO(),
&User{Name: "Alex001"})
+ assert.Nil(t, err)
+ assert.Equal(t, user.Name, "Alex Stocks from
UserProviderWithCustomGroupAndVersion")
+ assert.Equal(t, user.Age, 18)
}
diff --git a/integrate_test/dockercompose/docker-compose.yml
b/integrate_test/dockercompose/docker-compose.yml
index e9153023..11bbf48d 100644
--- a/integrate_test/dockercompose/docker-compose.yml
+++ b/integrate_test/dockercompose/docker-compose.yml
@@ -20,6 +20,18 @@ services:
test: "curl --fail
http://127.0.0.1:8848/nacos/v1/console/health/liveness || exit 1"
interval: 5s
+ polaris:
+ image: polarismesh/polaris-standalone:latest
+ container_name: polaris-standalone
+ privileged: true
+ ports:
+ - "8090:8090"
+ - "8091:8091"
+ - "8093:8093"
+ healthcheck:
+ test: "curl --fail http://127.0.0.1:8090 || exit 1"
+ interval: 5s
+
etcd:
image: "quay.io/coreos/etcd:v3.4.28"
container_name: etcd
diff --git a/start_integrate_test.sh b/start_integrate_test.sh
index cf68d181..9d8d1c5e 100755
--- a/start_integrate_test.sh
+++ b/start_integrate_test.sh
@@ -82,6 +82,10 @@ array+=("rpc/multi-protocols")
# async
array+=("async")
+# polaris
+array+=("compatibility/polaris/registry")
+array+=("compatibility/polaris/limit")
+
# error
array+=("error")