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

hefengen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shenyu-website.git


The following commit(s) were added to refs/heads/main by this push:
     new b4bd967126 Tcp plugin (#932)
b4bd967126 is described below

commit b4bd967126d9e47109301b371e4320b1140a74f0
Author: 杨文杰 <[email protected]>
AuthorDate: Mon Jul 24 15:25:33 2023 +0800

    Tcp plugin (#932)
    
    * add plugin jar
    
    * tcp-plugin
    
    * tcp-plugin
    
    * tcp-plugin
    
    * tcp-plugin
---
 docs/plugin-center/proxy/tcp-plugin.md             | 140 ++++++++++++++++++++
 .../current/plugin-center/proxy/tcp-plugin.md      | 141 +++++++++++++++++++++
 .../shenyu/plugin/tcp/gateway_start_port_log.png   | Bin 0 -> 136092 bytes
 .../shenyu/plugin/tcp/gateway_upstream_list.png    | Bin 0 -> 162960 bytes
 static/img/shenyu/plugin/tcp/init-tcp.png          | Bin 0 -> 80355 bytes
 static/img/shenyu/plugin/tcp/local.png             | Bin 0 -> 50912 bytes
 static/img/shenyu/plugin/tcp/redis-connection.png  | Bin 0 -> 7608 bytes
 static/img/shenyu/plugin/tcp/refresh_upstream.png  | Bin 0 -> 37821 bytes
 static/img/shenyu/plugin/tcp/zookeeper.png         | Bin 0 -> 109065 bytes
 9 files changed, 281 insertions(+)

diff --git a/docs/plugin-center/proxy/tcp-plugin.md 
b/docs/plugin-center/proxy/tcp-plugin.md
new file mode 100644
index 0000000000..2cda34820c
--- /dev/null
+++ b/docs/plugin-center/proxy/tcp-plugin.md
@@ -0,0 +1,140 @@
+---
+title: Tcp Plugin
+keywords: [ "Tcp" ]
+description: TcpPlugin
+---
+
+# 1. Overview
+
+## 1.1 Plugin name
+
+- Tcp Plugin
+
+## 1.2 Appropriate Scenario
+
+- A service that handles Tcp requests and forwards them to other Tcp protocols 
on the backend
+- Service load balancing
+
+## 1.3 Plugin functionality
+
+* Supports tcp proxy based on configured upstream list
+* The upstream list can be hot-synchronized to the gateway by the admin module
+* Support setting load balancing policy for requests, currently support shenyu 
load balancing module policy __Note__: When a connection is established with 
the gateway, after the connection is established, the traffic continues to stay 
in the upstream that has been selected by the load balancing module
+* Configurable open port for listening, configurable reactor-netty parameter
+* Enable multiple proxy selectors
+
+## 1.4 Plugin code
+
+- Core Module`shenyu-plugin-tcp` `shenyu-protocol-tcp`
+
+## 1.5 Added since which shenyu version
+
+- 2.6.0
+
+# 2. How to use plugin
+
+Start admin server search BasicConfig-Plugin for tcp plugins and click 
Resource to activate the current tcp module
+
+![init-tcp](/img/shenyu/plugin/tcp/init-tcp.png)
+
+## 2.1 Plugin Config
+
+Plugin configuration
+
+```json
+{
+  "loadBalanceAlgorithm": "random",
+  "bossGroupThreadCount": "1",
+  "workerGroupThreadCount": "12",
+  "clientMaxConnections": "20",
+  "clientMaxIdleTimeMs": "30000",
+  "clientMaxLifeTimeMs": "60000",
+  "clientPendingAcquireTimeout": "5",
+  "clientPendingAcquireMaxCount": "5"
+}
+```
+
+loadBalanceAlgorithm : shenyu load balancing algorithm is random by default
+bossGroupThreadCount , workerGroupThreadCount
+ReactorNetty TcpServer For configuration details, see  
`shenyu-protocol-tcp#TcpBootstrapServer#start`
+clientMaxConnections , clientMaxIdleTimeMs , clientMaxLifeTimeMs , 
clientPendingAcquireTimeout ,
+clientPendingAcquireMaxCount
+ReactorNetty `ConnectionProvider` For configuration details, see 
`shenyu-protocol-tcp#ConnectionContext`
+
+## 2.2 Discovery Module Support
+
+Discovery `Zookeeper` and `Local` modes are currently supported
+
+### 2.2.1 Zookeeper Mode
+
+![zookeeper.png](/img/shenyu/plugin/tcp/zookeeper.png)
+Configure the zookeeper link
+When you want to be registered to shenyu tcp proxy services registered to 
ListenerNode(default is `/shenyu/discovery`) under the temporary node
+
+data json:
+
+```json
+{
+  "protocol": "tcp",
+  "url": "127.0.0.1:6379",
+  "status": 1,
+  "weight": 1,
+  "props": "{}"
+}
+```
+
+If the registered data is not in the default json format: aliases can be set
+
+```json
+{
+  "${yourProtocol}": "tcp",
+  "${yourUrl}": "127.0.0.1:6379",
+  "${yourStatus}": 1,
+  "${yourWeight}": 1,
+  "${yourProps}": "{}"
+}
+```
+
+The discovery module will automatically listen to your zookeeper registry and 
automatically maintain discovery_upstream
+
+
+
+### 2.2.2 Local Mode
+
+discovery#Local config
+
+```json
+{
+  "baseSleepTimeMilliseconds": "1000",
+  "maxRetries": "3",
+  "maxSleepTimeMilliseconds": "1000",
+  "connectionTimeoutMilliseconds": "1000",
+  "sessionTimeoutMilliseconds": "1000",
+  "namespace": "",
+  "digest": null
+}
+```
+
+For details, see `shenyu-discovery-zookeeper#ZookeeperDiscoveryService#init`
+
+discovery#Local config
+Manually configure the forwarding port and downstream nodes
+![local.png](/img/shenyu/plugin/tcp/local.png)
+
+### 2.3 Shenyu log
+
+shenyu-gateway port start log
+![gateway_start_port_log.png](/img/shenyu/plugin/tcp/gateway_start_port_log.png)
+
+shenyu-gateway proxy upstreamList‘s success log
+![gateway_upstream_list.png](/img/shenyu/plugin/tcp/gateway_upstream_list.png)
+
+## 2.3 Using validation
+
+Take the proxy redis for example
+use `redis-cli -p {forwardPort}` 
+
+![connection.png](/img/shenyu/plugin/tcp/redis-connection.png)
+
+If there is a difference between the current admin's UpstreamList and the 
gateway's , you can click Refresh to force synchronization to the gateway
+![refresh_upstream.png](/img/shenyu/plugin/tcp/refresh_upstream.png)
diff --git 
a/i18n/zh/docusaurus-plugin-content-docs/current/plugin-center/proxy/tcp-plugin.md
 
b/i18n/zh/docusaurus-plugin-content-docs/current/plugin-center/proxy/tcp-plugin.md
new file mode 100644
index 0000000000..6b05873bf9
--- /dev/null
+++ 
b/i18n/zh/docusaurus-plugin-content-docs/current/plugin-center/proxy/tcp-plugin.md
@@ -0,0 +1,141 @@
+---
+title: Tcp插件
+keywords: [ "Tcp" ]
+description: Tcp插件
+---
+
+# 1. 概述
+
+## 1.1 插件名称
+
+- Tcp插件
+
+## 1.2 适用场景
+
+- 处理 Tcp协议 请求,将其转发到后端其他 Tcp 协议的服务
+- 服务负载均衡
+
+## 1.3 插件功能
+
+* 支持根据 配置的 upstream list 做tcp代理
+* upstream list 可在 admin 模块自行配置 热同步到 gateway
+* 支持设置请求的负载均衡策略,目前支持 shenyu 负载均衡模块的策略 注意: 负载均衡作用与和gateway建立连接时,当连接建立后续的流量继续保持
+  负载均衡模块 已经选定的upstream
+* 支持配置开启端口进行监听, 可配置 reactor-netty 参数
+* 支持开启多个代理选择器
+
+## 1.4 插件代码
+
+- 核心模块`shenyu-plugin-tcp` `shenyu-protocol-tcp`
+
+## 1.5 添加自哪个shenyu版本
+
+- 2.6.0
+
+# 2. 如何使用插件
+
+启动 admin server 在 BasicConfig - Plugin 中 搜索 tcp 插件 并且 点击 Resource 激活当前 tcp 模块
+
+![init-tcp](/img/shenyu/plugin/tcp/init-tcp.png)
+
+## 2.1 插件配置
+
+插件配置
+
+```json
+{
+  "loadBalance": "random",
+  "bossGroupThreadCount": "1",
+  "workerGroupThreadCount": "12",
+  "clientMaxConnections": "20",
+  "clientMaxIdleTimeMs": "30000",
+  "clientMaxLifeTimeMs": "60000",
+  "clientPendingAcquireTimeout": "5",
+  "clientPendingAcquireMaxCount": "5"
+}
+```
+
+loadBalanceAlgorithm : shenyu负载均衡算法 默认random
+bossGroupThreadCount , workerGroupThreadCount
+ReactorNetty TcpServer 配置 详情见  `shenyu-protocol-tcp#TcpBootstrapServer#start`
+clientMaxConnections , clientMaxIdleTimeMs , clientMaxLifeTimeMs , 
clientPendingAcquireTimeout ,
+clientPendingAcquireMaxCount
+ReactorNetty `ConnectionProvider` 配置 详情见 
`shenyu-protocol-tcp#ConnectionContext`
+
+## 2.2 Discovery 支持
+
+目前 支持 Discovery Zookeeper 和 Local 模式
+
+### 2.2.1 Zookeeper 模式
+
+![zookeeper.png](/img/shenyu/plugin/tcp/zookeeper.png)
+配置 zookeeper 链接地址
+当你要被注册到 shenyu tcp代理的 服务 注册到 ListenerNode 若不配置自动为 `/shenyu/discovery` 下的 临时节点
+
+数据为:
+
+```json
+{
+  "protocol": "tcp",
+  "url": "127.0.0.1:6379",
+  "status": 1,
+  "weight": 1,
+  "props": "{}"
+}
+```
+
+若注册的数据与 默认的json格式不同时: 可以设置别名  
+
+```json
+{
+  "${yourProtocol}": "tcp",
+  "${yourUrl}": "127.0.0.1:6379",
+  "${yourStatus}": 1,
+  "${yourWeight}": 1,
+  "${yourProps}": "{}"
+}
+```
+
+discovery 模块会自动 监听到 你的 zookeeper 注册中心 自动维护 discovery_upstream
+
+
+
+### 2.2.2 Local 模式
+
+discovery#Local 配置
+
+```json
+{
+  "baseSleepTimeMilliseconds": "1000",
+  "maxRetries": "3",
+  "maxSleepTimeMilliseconds": "1000",
+  "connectionTimeoutMilliseconds": "1000",
+  "sessionTimeoutMilliseconds": "1000",
+  "namespace": "",
+  "digest": null
+}
+```
+
+详情见 `shenyu-discovery-zookeeper#ZookeeperDiscoveryService#init`
+
+discovery#Local 配置
+手动配置 转发端口 和 下游节点
+![local.png](/img/shenyu/plugin/tcp/local.png)
+
+shenyu-gateway 端口启动log
+![gateway_start_port_log.png](/img/shenyu/plugin/tcp/gateway_start_port_log.png)
+
+shenyu-gateway 代理列表同步log
+![gateway_upstream_list.png](/img/shenyu/plugin/tcp/gateway_upstream_list.png)
+
+## 使用
+
+以 代理 redis 为例
+使用 `redis-cli -p {forwardPort}` 访问
+
+![connection.png](/img/shenyu/plugin/tcp/redis-connection.png)
+
+
+如果当前 admin 的  UpstreamList 与 gateway 出现差异时可以 点击刷新 强制同步到gateway
+
+![refresh_upstream.png](/img/shenyu/plugin/tcp/refresh_upstream.png)
diff --git a/static/img/shenyu/plugin/tcp/gateway_start_port_log.png 
b/static/img/shenyu/plugin/tcp/gateway_start_port_log.png
new file mode 100644
index 0000000000..58e11cd0c7
Binary files /dev/null and 
b/static/img/shenyu/plugin/tcp/gateway_start_port_log.png differ
diff --git a/static/img/shenyu/plugin/tcp/gateway_upstream_list.png 
b/static/img/shenyu/plugin/tcp/gateway_upstream_list.png
new file mode 100644
index 0000000000..f43f415b10
Binary files /dev/null and 
b/static/img/shenyu/plugin/tcp/gateway_upstream_list.png differ
diff --git a/static/img/shenyu/plugin/tcp/init-tcp.png 
b/static/img/shenyu/plugin/tcp/init-tcp.png
new file mode 100644
index 0000000000..95a0e2b184
Binary files /dev/null and b/static/img/shenyu/plugin/tcp/init-tcp.png differ
diff --git a/static/img/shenyu/plugin/tcp/local.png 
b/static/img/shenyu/plugin/tcp/local.png
new file mode 100644
index 0000000000..4c11a14d92
Binary files /dev/null and b/static/img/shenyu/plugin/tcp/local.png differ
diff --git a/static/img/shenyu/plugin/tcp/redis-connection.png 
b/static/img/shenyu/plugin/tcp/redis-connection.png
new file mode 100644
index 0000000000..206530df95
Binary files /dev/null and b/static/img/shenyu/plugin/tcp/redis-connection.png 
differ
diff --git a/static/img/shenyu/plugin/tcp/refresh_upstream.png 
b/static/img/shenyu/plugin/tcp/refresh_upstream.png
new file mode 100644
index 0000000000..8374a63dcd
Binary files /dev/null and b/static/img/shenyu/plugin/tcp/refresh_upstream.png 
differ
diff --git a/static/img/shenyu/plugin/tcp/zookeeper.png 
b/static/img/shenyu/plugin/tcp/zookeeper.png
new file mode 100644
index 0000000000..27abade97d
Binary files /dev/null and b/static/img/shenyu/plugin/tcp/zookeeper.png differ

Reply via email to