This is an automated email from the ASF dual-hosted git repository.

xuetaoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-website.git


The following commit(s) were added to refs/heads/master by this push:
     new 0503316ce1e docs(golang): write docs for router (#3194)
0503316ce1e is described below

commit 0503316ce1e4520905d8bfa346259b124319525f
Author: yangpixi <[email protected]>
AuthorDate: Fri Mar 6 14:20:04 2026 +0800

    docs(golang): write docs for router (#3194)
    
    * docs(golang): write docs for router
    
    * docs(golang): refine docs
    
    * docs(golang): refine docs
    
    * docs(golang): translate router docs to english
    
    * docs(golang): divide original docs into four parts, remove useless 
description.
    
    * docs(golang): change non-existent file url
---
 .../golang-sdk/tutorial/traffic/affinity_router.md |  8 ++
 .../tutorial/traffic/condition_router.md           | 88 ++++++++++++++++++++++
 .../mannual/golang-sdk/tutorial/traffic/router.md  | 11 ---
 .../golang-sdk/tutorial/traffic/script_router.md   | 47 ++++++++++++
 .../golang-sdk/tutorial/traffic/tag_router.md      | 66 ++++++++++++++++
 .../golang/dubbo-go-3.0/samples/mesh_router.md     |  2 +-
 .../golang-sdk/tutorial/traffic/affinity_router.md |  0
 .../tutorial/traffic/condition_router.md           | 87 +++++++++++++++++++++
 .../mannual/golang-sdk/tutorial/traffic/router.md  | 11 ---
 .../golang-sdk/tutorial/traffic/script_router.md   | 49 ++++++++++++
 .../golang-sdk/tutorial/traffic/tag_router.md      | 63 ++++++++++++++++
 11 files changed, 409 insertions(+), 23 deletions(-)

diff --git 
a/content/en/overview/mannual/golang-sdk/tutorial/traffic/affinity_router.md 
b/content/en/overview/mannual/golang-sdk/tutorial/traffic/affinity_router.md
new file mode 100644
index 00000000000..9b25a4ede93
--- /dev/null
+++ b/content/en/overview/mannual/golang-sdk/tutorial/traffic/affinity_router.md
@@ -0,0 +1,8 @@
+---
+description: Affinity Router
+title: Affinity Router
+type: docs
+weight: 1
+---
+
+
diff --git 
a/content/en/overview/mannual/golang-sdk/tutorial/traffic/condition_router.md 
b/content/en/overview/mannual/golang-sdk/tutorial/traffic/condition_router.md
new file mode 100644
index 00000000000..d2c0a804e2e
--- /dev/null
+++ 
b/content/en/overview/mannual/golang-sdk/tutorial/traffic/condition_router.md
@@ -0,0 +1,88 @@
+---
+description: Condition Router
+title: Condition Router
+type: docs
+weight: 1
+---
+
+## How to use
+
+### Prerequisites
+
+- Docker and Docker Compose environment to deploy Nacos registry.
+- Nacos Version 2.x+
+- Go 1.23+
+
+#### Run Nacos
+
+Follow this instruction
+to [install and start Nacos 
server](https://dubbo-next.staged.apache.org/zh-cn/overview/reference/integrations/nacos/).
+
+### Condition router
+
+Similar to the Tag Router, the condition router offers more advanced traffic 
control capabilities.
+It uses `consumer => provider` expressions to manage traffic for both 
providers and consumers.
+
+Expression example:
+
+`host = 127.0.0.1 => host = 127.0.0.1, 192.168.1.1`
+
+> You can use = and != symbols for matching, and use commas for multiple 
choice matching.
+
+Here's the example code.
+
+Server side:
+
+```go
+ins, err := dubbo.NewInstance(
+               dubbo.WithName("condition-server"),
+               dubbo.WithRegistry(
+                       registry.WithNacos(),
+                       registry.WithAddress(RegistryAddress),
+               ),
+               dubbo.WithProtocol(
+                       protocol.WithTriple(),
+                       protocol.WithPort(TriPort),
+               ),
+       )
+```
+
+Client side:
+
+```go
+ins, err := dubbo.NewInstance(
+               dubbo.WithName("condition-client"),
+               dubbo.WithRegistry(
+                       registry.WithNacos(),
+                       registry.WithAddress(RegistryAddress),
+               ),
+               dubbo.WithConfigCenter( // configure config center to enable 
condition router
+                       config_center.WithNacos(),
+                       config_center.WithAddress(RegistryAddress),
+               ),
+       )
+rep, err := srv.Greet(context.Background(), &greet.GreetRequest{Name: "hello 
world"})
+```
+
+> A configuration in Nacos is needed if you want to use condition router.
+
+Example config:
+
+> The `Data Id` of config must be `{application_name}.{router_type}` (e.g. 
condition-server.condition-router).
+
+```yaml
+configVersion: v3.1
+scope: "application"
+key: "condition-server"
+priority: 1
+force: true
+enabled: false
+conditions:
+  - from:
+      match: "application = condition-client"
+    to:
+      - match: "port = 20000"
+```
+
+For the complete example, please
+see: [Full Example 
Code](https://github.com/apache/dubbo-go-samples/tree/main/router/condition).
\ No newline at end of file
diff --git a/content/en/overview/mannual/golang-sdk/tutorial/traffic/router.md 
b/content/en/overview/mannual/golang-sdk/tutorial/traffic/router.md
deleted file mode 100644
index 47434cbc0e5..00000000000
--- a/content/en/overview/mannual/golang-sdk/tutorial/traffic/router.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-aliases:
-    - /en/docs3-v2/golang-sdk/tutorial/governance/traffic/mesh_router/
-    - /en/docs3-v2/golang-sdk/tutorial/governance/traffic/mesh_router/
-    - /en/overview/mannual/golang-sdk/tutorial/governance/traffic/mesh_router/
-description: Routing Rules
-title: Routing Rules
-type: docs
-weight: 1
----
-
diff --git 
a/content/en/overview/mannual/golang-sdk/tutorial/traffic/script_router.md 
b/content/en/overview/mannual/golang-sdk/tutorial/traffic/script_router.md
new file mode 100644
index 00000000000..a294c5406a8
--- /dev/null
+++ b/content/en/overview/mannual/golang-sdk/tutorial/traffic/script_router.md
@@ -0,0 +1,47 @@
+---
+description: Script Router
+title: Script Router
+type: docs
+weight: 1
+---
+
+## How to use
+
+### Prerequisites
+
+- Docker and Docker Compose environment to deploy Nacos registry.
+- Nacos Version 2.x+
+- Go 1.23+
+
+#### Run Nacos
+
+Follow this instruction
+to [install and start Nacos 
server](https://dubbo-next.staged.apache.org/zh-cn/overview/reference/integrations/nacos/).
+
+### Script router
+
+Similar to the condition router, the script router enables traffic control 
using expressions. However,
+while it offers more powerful matching capabilities, this comes at the cost of 
higher resource consumption.
+Therefore, it should be used sparingly in production environments.
+
+The example code for the script router is similar to that of the condition 
router,
+with slight differences in the Nacos configuration.
+Therefore, only the Nacos configuration is provided here.
+
+```yaml
+scope: "application"
+key: "script-server"
+enabled: true
+type: "javascript"
+script: |
+  (function(invokers, invocation, context) {
+    if (!invokers || invokers.length === 0) return [];
+    return invokers.filter(function(invoker) {
+      var url = invoker.GetURL();
+      return url && url.Port === "20000";
+    });
+  })(invokers, invocation, context);
+```
+
+For the complete example, please
+see: [Full Example 
Code](https://github.com/apache/dubbo-go-samples/tree/main/router/script).
\ No newline at end of file
diff --git 
a/content/en/overview/mannual/golang-sdk/tutorial/traffic/tag_router.md 
b/content/en/overview/mannual/golang-sdk/tutorial/traffic/tag_router.md
new file mode 100644
index 00000000000..09a81eb1603
--- /dev/null
+++ b/content/en/overview/mannual/golang-sdk/tutorial/traffic/tag_router.md
@@ -0,0 +1,66 @@
+---
+description: Tag Router
+title: Tag Router
+type: docs
+weight: 1
+---
+
+## How to use
+
+### Prerequisites
+
+- Docker and Docker Compose environment to deploy Nacos registry.
+- Nacos Version 2.x+
+- Go 1.23+
+
+#### Run Nacos
+
+Follow this instruction
+to [install and start Nacos 
server](https://dubbo-next.staged.apache.org/zh-cn/overview/reference/integrations/nacos/).
+
+### Tag router
+
+The tag router enables traffic control based on tags. The following is the 
example code.
+
+Server side:
+
+```go
+ins, err := dubbo.NewInstance(
+               dubbo.WithName("tag-server"),
+               dubbo.WithTag("test-Tag"), // set application's tag
+               dubbo.WithRegistry(
+                       registry.WithNacos(),
+                       registry.WithAddress(RegistryAddress),
+               ),
+               dubbo.WithProtocol(
+                       protocol.WithTriple(),
+                       protocol.WithPort(20000),
+               ),
+       )
+```
+
+Parameters:
+
+- dubbo.WithTag: Sets tag that the instance carries, which used to mark the 
instance (e.g. Canary Env).
+
+Client side:
+
+```go
+atta := map[string]string{
+       constant.Tagkey:      "test-tag",
+       constant.ForceUseTag: "true", // 使用string类型
+}
+ctx := context.WithValue(context.Background(), constant.AttachmentKey, atta)
+resp, err := svc.Greet(ctx, &greet.GreetRequest{Name: name})
+```
+
+Parameters:
+
+- `constant.TagKey`: Sets tag that requests carry.
+- `constant.ForceUseTag`: Sets whether to force tag matching.
+
+> Untagged traffic is routed only to untagged servers. Tagged traffic can be 
routed to servers with matching tags or
+> to untagged servers, depending on the force configuration.
+
+For the complete example, please
+see: [Full Example 
Code](https://github.com/apache/dubbo-go-samples/tree/main/router/tag).
diff --git 
a/content/zh-cn/docs/languages/golang/dubbo-go-3.0/samples/mesh_router.md 
b/content/zh-cn/docs/languages/golang/dubbo-go-3.0/samples/mesh_router.md
index 487a1e39a52..d8c7e8554f7 100644
--- a/content/zh-cn/docs/languages/golang/dubbo-go-3.0/samples/mesh_router.md
+++ b/content/zh-cn/docs/languages/golang/dubbo-go-3.0/samples/mesh_router.md
@@ -10,7 +10,7 @@ type: docs
 
 
 
-{{% pageinfo %}} 
此文档已经不再维护。您当前查看的是快照版本。如果想要查看最新版本的文档,请参阅[最新版本](/zh-cn/overview/mannual/golang-sdk/tutorial/governance/traffic/mesh_router/)。
+{{% pageinfo %}} 
此文档已经不再维护。您当前查看的是快照版本。如果想要查看最新版本的文档,请参阅[最新版本](/zh-cn/overview/mannual/golang-sdk/tutorial/traffic)。
 {{% /pageinfo %}}
 
 # Dubbo-go v3 Mesh路由规则
diff --git 
a/content/zh-cn/overview/mannual/golang-sdk/tutorial/traffic/affinity_router.md 
b/content/zh-cn/overview/mannual/golang-sdk/tutorial/traffic/affinity_router.md
new file mode 100644
index 00000000000..e69de29bb2d
diff --git 
a/content/zh-cn/overview/mannual/golang-sdk/tutorial/traffic/condition_router.md
 
b/content/zh-cn/overview/mannual/golang-sdk/tutorial/traffic/condition_router.md
new file mode 100644
index 00000000000..781e353928d
--- /dev/null
+++ 
b/content/zh-cn/overview/mannual/golang-sdk/tutorial/traffic/condition_router.md
@@ -0,0 +1,87 @@
+---
+description: 条件路由
+title: 条件路由
+type: docs
+weight: 1
+---
+
+## 使用方法
+
+### 前置准备
+
+- Docker 以及 Docker compose 环境来部署Nacos配置中心。
+- Nacos 2.x+
+- Go 1.23+
+
+#### 启动Nacos配置中心
+
+参考这个教程来[启动Nacos](https://dubbo-next.staged.apache.org/zh-cn/overview/reference/integrations/nacos/)。
+
+### Condition router 介绍
+
+Condition router 与 Tag router 类似,但是提供了更强大的流量管控功能,可以通过表达式`consumer => provider`,
+对服务端以及客户端进行流量管控。
+
+匹配表达式示例:
+
+`host = 127.0.0.1 => host = 127.0.0.1, 192.168.1.1`
+
+> 可以使用 = 以及 != 等符号进行匹配,使用逗号进行多选择匹配。
+
+示例代码:
+
+服务端部分:
+
+```go
+ins, err := dubbo.NewInstance(
+               dubbo.WithName("condition-server"),
+               dubbo.WithRegistry(
+                       registry.WithNacos(),
+                       registry.WithAddress(RegistryAddress),
+               ),
+               dubbo.WithProtocol(
+                       protocol.WithTriple(),
+                       protocol.WithPort(TriPort),
+               ),
+       )
+```
+
+客户端部分:
+
+```go
+ins, err := dubbo.NewInstance(
+               dubbo.WithName("condition-client"),
+               dubbo.WithRegistry(
+                       registry.WithNacos(),
+                       registry.WithAddress(RegistryAddress),
+               ),
+               dubbo.WithConfigCenter( // configure config center to enable 
condition router
+                       config_center.WithNacos(),
+                       config_center.WithAddress(RegistryAddress),
+               ),
+       )
+rep, err := srv.Greet(context.Background(), &greet.GreetRequest{Name: "hello 
world"})
+```
+
+> 使用condition router必须在nacos等配置中心动态设置匹配规则。
+
+Nacos配置示例:
+
+> 配置的`Data ID`名字必须为: `{application_name}.{router_type}`。
+> 例如: `condition-server.condition-router`。
+
+```yaml
+configVersion: v3.1
+scope: "application"
+key: "condition-server"
+priority: 1
+force: true
+enabled: false
+conditions:
+  - from:
+      match: "application = condition-client"
+    to:
+      - match: "port = 20000"
+```
+
+完整示例请见: 
[本示例完整代码](https://github.com/apache/dubbo-go-samples/tree/main/router/condition)。
\ No newline at end of file
diff --git 
a/content/zh-cn/overview/mannual/golang-sdk/tutorial/traffic/router.md 
b/content/zh-cn/overview/mannual/golang-sdk/tutorial/traffic/router.md
deleted file mode 100644
index 31b2e5b3190..00000000000
--- a/content/zh-cn/overview/mannual/golang-sdk/tutorial/traffic/router.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-aliases:
-    - /zh/docs3-v2/golang-sdk/tutorial/governance/traffic/mesh_router/
-    - /zh-cn/docs3-v2/golang-sdk/tutorial/governance/traffic/mesh_router/
-    - 
/zh-cn/overview/mannual/golang-sdk/tutorial/governance/traffic/mesh_router/
-description: 路由规则
-title: 路由规则
-type: docs
-weight: 1
----
-
diff --git 
a/content/zh-cn/overview/mannual/golang-sdk/tutorial/traffic/script_router.md 
b/content/zh-cn/overview/mannual/golang-sdk/tutorial/traffic/script_router.md
new file mode 100644
index 00000000000..8b54831c2ea
--- /dev/null
+++ 
b/content/zh-cn/overview/mannual/golang-sdk/tutorial/traffic/script_router.md
@@ -0,0 +1,49 @@
+---
+description: 脚本路由
+title: 脚本路由
+type: docs
+weight: 1
+---
+
+## 使用方法
+
+### 前置准备
+
+- Docker 以及 Docker compose 环境来部署Nacos配置中心。
+- Nacos 2.x+
+- Go 1.23+
+
+#### 启动Nacos配置中心
+
+参考这个教程来[启动Nacos](https://dubbo-next.staged.apache.org/zh-cn/overview/reference/integrations/nacos/)。
+
+### Script router 介绍
+
+Script router与condition router类似,都提供了使用表达式进行流量管控的功能。
+但是Script router具有更强大的匹配功能,与此同时带来的是匹配消耗的资源更多,因此在生产环境中应当尽量少使用。
+
+Script router的示例代码与Condition router类似,在nacos配置上略有差别,这里仅提供nacos上的简单配置。
+
+```yaml
+scope: "application"
+key: "script-server"
+enabled: true
+type: "javascript"
+script: |
+  (function(invokers, invocation, context) {
+    if (!invokers || invokers.length === 0) return [];
+    return invokers.filter(function(invoker) {
+      var url = invoker.GetURL();
+      return url && url.Port === "20000";
+    });
+  })(invokers, invocation, context);
+```
+
+参数说明:
+
+| 参数     | 说明                 |
+|--------|--------------------|
+| type   | script的类型,目前仅可使用js |
+| script | script实际内容         |
+
+完整示例请见: 
[本示例完整代码](https://github.com/apache/dubbo-go-samples/tree/main/router/script)。
\ No newline at end of file
diff --git 
a/content/zh-cn/overview/mannual/golang-sdk/tutorial/traffic/tag_router.md 
b/content/zh-cn/overview/mannual/golang-sdk/tutorial/traffic/tag_router.md
new file mode 100644
index 00000000000..e53bed2c733
--- /dev/null
+++ b/content/zh-cn/overview/mannual/golang-sdk/tutorial/traffic/tag_router.md
@@ -0,0 +1,63 @@
+---
+description: 标签路由
+title: 标签路由
+type: docs
+weight: 1
+---
+
+## 使用方法
+
+### 前置准备
+
+- Docker 以及 Docker compose 环境来部署Nacos配置中心。
+- Nacos 2.x+
+- Go 1.23+
+
+#### 启动Nacos配置中心
+
+参考这个教程来[启动Nacos](https://dubbo-next.staged.apache.org/zh-cn/overview/reference/integrations/nacos/)。
+
+### Tag router 介绍
+
+Tag router可以通过标签对流量进行管控,以下为示例代码。
+
+服务端部分:
+
+```go
+ins, err := dubbo.NewInstance(
+               dubbo.WithName("tag-server"),
+               dubbo.WithTag("test-Tag"), // set application's tag
+               dubbo.WithRegistry(
+                       registry.WithNacos(),
+                       registry.WithAddress(RegistryAddress),
+               ),
+               dubbo.WithProtocol(
+                       protocol.WithTriple(),
+                       protocol.WithPort(20000),
+               ),
+       )
+```
+
+参数:
+
+- dubbo.WithTag: 设置该实例携带的tag,用于标记该实例(例如为灰度环境等)。
+
+客户端部分:
+
+```go
+atta := map[string]string{
+       constant.Tagkey:      "test-tag",
+       constant.ForceUseTag: "true", // 使用string类型
+}
+ctx := context.WithValue(context.Background(), constant.AttachmentKey, atta)
+resp, err := svc.Greet(ctx, &greet.GreetRequest{Name: name})
+```
+
+参数:
+
+- `constant.TagKey`: 设置客户端发送请求时所携带的tag标签。
+- `constant.ForceUseTag`: 设置是否强制匹配标签。
+
+> 未携带标签的流量只能打到未携带标签的服务,携带标签的流量则可以打到携带相应标签的服务以及不具有标签的服务(取决于是否配置force参数)。
+
+完整示例请见: 
[本示例完整代码](https://github.com/apache/dubbo-go-samples/tree/main/router/tag)。
\ No newline at end of file

Reply via email to