This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu-website.git
The following commit(s) were added to refs/heads/main by this push:
new 9c05d60 support register different type api at same time. (#333)
9c05d60 is described below
commit 9c05d600ead9a18383ffd1fe0e50d3d72dc4714a
Author: Qicz <[email protected]>
AuthorDate: Wed Oct 27 11:06:35 2021 +0800
support register different type api at same time. (#333)
---
docs/user-guide/register-center-access.md | 108 +++++++++++++++------
.../current/user-guide/register-center-access.md | 105 ++++++++++++++------
2 files changed, 150 insertions(+), 63 deletions(-)
diff --git a/docs/user-guide/register-center-access.md
b/docs/user-guide/register-center-access.md
index 367b100..cb41516 100644
--- a/docs/user-guide/register-center-access.md
+++ b/docs/user-guide/register-center-access.md
@@ -25,9 +25,9 @@ shenyu:
register:
registerType: http
props:
- checked: true # is checked
- zombieCheckTimes: 5 # how many times does it fail to detect the service
- scheduledTime: 10 # timed detection interval time
+ checked: true # is checked
+ zombieCheckTimes: 5 # how many times does it fail to detect the service
+ scheduledTime: 10 # timed detection interval time
```
<img src="/img/shenyu/register/register-http-admin-yml.png" width="70%"
height="60%" />
@@ -42,18 +42,19 @@ shenyu:
client:
registerType: http
serverLists: http://localhost:9095
- props:
- contextPath: /http
- appName: http
- port: 8188
- isFull: false
+ http:
+ props:
+ contextPath: /http
+ appName: http
+ port: 8188
+ isFull: false
# registerType : register type, set http
# serverList: when register type is http,set shenyu-admin address list,pls
note 'http://' is necessary.
# port: your project port number; apply to springmvc/tars/grpc
# contextPath: your project's route prefix through shenyu gateway, such as
/order ,/product etc,gateway will route based on it.
# appName:your project name,the default value is`spring.application.name`.
# isFull: set true means providing proxy for your entire service, or only a
few controller. apply to springmvc/springcloud
-```
+```
<img src="/img/shenyu/register/register-http-client-yml.png" width="70%"
height="60%" />
@@ -118,18 +119,19 @@ shenyu:
client:
registerType: zookeeper
serverLists: localhost:2181
- props:
- contextPath: /http
- appName: http
- port: 8189
- isFull: false
+ http:
+ props:
+ contextPath: /http
+ appName: http
+ port: 8189
+ isFull: false
# registerType : register type, set zookeeper
# serverList: when register type is zookeeper,set zookeeper address list
# port: your project port number; apply to springmvc/tars/grpc
# contextPath: your project's route prefix through shenyu gateway, such as
/order ,/product etc,gateway will route based on it.
# appName:your project name,the default value is`spring.application.name`.
# isFull: set true means providing proxy for your entire service, or only a
few controller. apply to springmvc/springcloud
-```
+```
<img src="/img/shenyu/register/register-zk-client-yml.png" width="70%"
height="60%" />
@@ -193,18 +195,19 @@ shenyu:
client:
registerType: etcd
serverLists: http://localhost:2379
- props:
- contextPath: /http
- appName: http
- port: 8189
- isFull: false
+ http:
+ props:
+ contextPath: /http
+ appName: http
+ port: 8189
+ isFull: false
# registerType : register type, set etcd
# serverList: when register type is etcd, add etcd address list
# port: your project port number; apply to springmvc/tars/grpc
# contextPath: your project's route prefix through shenyu gateway, such as
/order ,/product etc,gateway will route based on it.
# appName:your project name,the default value is`spring.application.name`.
# isFull: set true means providing proxy for your entire service, or only a
few controller. apply to springmvc/springcloud
-```
+```
<img src="/img/shenyu/register/register-etcd-client-yml.png" width="70%"
height="60%" />
@@ -298,11 +301,12 @@ The following shows the configuration information
registered by `Consul` when th
shenyu:
client:
registerType: consul
- props:
- contextPath: /http
- appName: http
- port: 8188
- isFull: false
+ http:
+ props:
+ contextPath: /http
+ appName: http
+ port: 8188
+ isFull: false
spring:
cloud:
@@ -378,18 +382,20 @@ The following shows the configuration information
registered by `Nacos` when the
<img src="/img/shenyu/register/register-nacos-client-pom.png" width="70%"
height="60%" />
-* Then in `yml` configure registration mode as `naco`, and fill in `nacos`
service address and related parameters, also need `nacos` namespace (need to be
consistent with `shenyu-admin`), IP (optional, then automatically obtain the
local IP address) and port, configuration information is as follows:
+* Then in `yml` configure registration mode as `nacos`, and fill in `nacos`
service address and related parameters, also need `nacos` namespace (need to be
consistent with `shenyu-admin`), IP (optional, then automatically obtain the
local IP address) and port, configuration information is as follows:
```yaml
shenyu:
client:
registerType: nacos
serverLists: localhost:8848
+ http:
+ props:
+ contextPath: /http
+ appName: http
+ port: 8188
+ isFull: false
props:
- contextPath: /http
- appName: http
- port: 8188
- isFull: false
nacosNameSpace: ShenyuRegisterCenter
# registerType : register type, set nacos
# serverList: when register type is nacos, add nacos address list
@@ -398,9 +404,47 @@ shenyu:
# appName:your project name,the default value is`spring.application.name`.
# isFull: set true means providing proxy for your entire service, or only a
few controller. apply to springmvc/springcloud
# nacosNameSpace: nacos namespace
-```
+```
<img src="/img/shenyu/register/register-nacos-client-yml.png" width="70%"
height="60%" />
+### Register different type API at same time
+
+> follow example use the http and dubbo.
+
+the `yml` configuration like follow:
+
+```yaml
+shenyu:
+ client:
+ registerType: nacos
+ serverLists: localhost:8848
+ http:
+ props:
+ contextPath: /http
+ appName: http
+ port: 8188
+ isFull: false
+ dubbo:
+ props:
+ contextPath: /dubbo
+ appName: dubbo
+ port: 28080
+ props:
+ nacosNameSpace: ShenyuRegisterCenter
+# registerType : register type, set nacos
+# serverList: when register type is nacos, add nacos address list
+# http.port: your project port number; apply to springmvc
+# http.contextPath: your project's route prefix through shenyu gateway, such
as /order ,/product etc,gateway will route based on it.
+# http.appName:your project name,the default value is`spring.application.name`.
+# http.isFull: set true means providing proxy for your entire service, or only
a few controller. apply to springmvc/springcloud
+# dubbo.contextPath: your project dubbo service's context path
+# dubbo.port: your project dubbo rpc port
+# dubbo.appName: your project dubbo appliation name
+# nacosNameSpace: nacos namespace
+```
+
+
+
In conclusion, this paper mainly describes how to connect your microservices
(currently supporting `Http`, `Dubbo`, `Spring Cloud`, `gRPC`, `Motan`, `Sofa`,
`Tars` and other protocols) to the `Apache ShenYu` gateway. the Apache ShenYu
gateway support registry has `Http`, `Zookeeper`, `Etcd`, `Consul`, `Nacos` and
so on. This paper introduces the different ways to register configuration
information when `Http` service is used as the client to access `Apache ShenYu`
gateway.
diff --git
a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/register-center-access.md
b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/register-center-access.md
index 2fb4213..942dbe2 100644
---
a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/register-center-access.md
+++
b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/register-center-access.md
@@ -45,18 +45,19 @@ shenyu:
client:
registerType: http
serverLists: http://localhost:9095
- props:
- contextPath: /http
- appName: http
- port: 8188
- isFull: false
+ http:
+ props:
+ contextPath: /http
+ appName: http
+ port: 8188
+ isFull: false
# registerType : 服务注册类型,填写 http
# serverList: 为http注册类型时,填写Shenyu-Admin项目的地址,注意加上http://,多个地址用英文逗号分隔
# port: 你本项目的启动端口,目前springmvc/tars/grpc需要进行填写
# contextPath: 为你的这个mvc项目在shenyu网关的路由前缀, 比如/order ,/product
等等,网关会根据你的这个前缀来进行路由.
# appName:你的应用名称,不配置的话,会默认取 `spring.application.name` 的值
# isFull: 设置true
代表代理你的整个服务,false表示代理你其中某几个controller;目前适用于springmvc/springcloud
-```
+```
<img src="/img/shenyu/register/register-http-client-yml.png" width="70%"
height="60%" />
@@ -117,18 +118,19 @@ shenyu:
client:
registerType: zookeeper
serverLists: localhost:2181
- props:
- contextPath: /http
- appName: http
- port: 8189
- isFull: false
+ http:
+ props:
+ contextPath: /http
+ appName: http
+ port: 8189
+ isFull: false
# registerType : 服务注册类型,填写 zookeeper
# serverList: 为zookeeper注册类型时,填写zookeeper地址,多个地址用英文逗号分隔
# port: 你本项目的启动端口,目前springmvc/tars/grpc需要进行填写
# contextPath: 为你的这个mvc项目在shenyu网关的路由前缀, 比如/order ,/product
等等,网关会根据你的这个前缀来进行路由.
# appName:你的应用名称,不配置的话,会默认取 `spring.application.name` 的值
# isFull: 设置true
代表代理你的整个服务,false表示代理你其中某几个controller;目前适用于springmvc/springcloud
-```
+```
<img src="/img/shenyu/register/register-zk-client-yml.png" width="70%"
height="60%" />
@@ -187,18 +189,19 @@ shenyu:
client:
registerType: etcd
serverLists: http://localhost:2379
- props:
- contextPath: /http
- appName: http
- port: 8189
- isFull: false
+ http:
+ props:
+ contextPath: /http
+ appName: http
+ port: 8189
+ isFull: false
# registerType : 服务注册类型,填写 etcd
# serverList: 为etcd注册类型时,填写etcd地址,多个地址用英文逗号分隔
# port: 你本项目的启动端口,目前springmvc/tars/grpc需要进行填写
# contextPath: 为你的这个mvc项目在shenyu网关的路由前缀, 比如/order ,/product
等等,网关会根据你的这个前缀来进行路由.
# appName:你的应用名称,不配置的话,会默认取 `spring.application.name` 的值
# isFull: 设置true
代表代理你的整个服务,false表示代理你其中某几个controller;目前适用于springmvc/springcloud
-```
+```
<img src="/img/shenyu/register/register-etcd-client-yml.png" width="70%"
height="60%" />
@@ -294,12 +297,13 @@ spring:
```yaml
shenyu:
client:
- registerType: consul
- props:
- contextPath: /http
- appName: http
- port: 8188
- isFull: false
+ registerType: consul
+ http:
+ props:
+ contextPath: /http
+ appName: http
+ port: 8188
+ isFull: false
spring:
cloud:
@@ -318,11 +322,10 @@ spring:
# service-name 服务注册到consul时所在的组名,不配置的话,会默认取 `spring.application.name` 的值
# host: 为 consul 注册类型时,填写 consul 地址,默认localhost
# spring.cloud.consul.port: 为 consul 注册类型时,填写 consul 端口, 默认是8500
-```
+```
<img src="/img/shenyu/register/register-consul-client-yml.png" width="70%"
height="60%" />
-
### Nacos方式注册配置
#### shenyu-admin配置
@@ -379,11 +382,13 @@ shenyu:
client:
registerType: nacos
serverLists: localhost:8848
+ http:
+ props:
+ contextPath: /http
+ appName: http
+ port: 8188
+ isFull: false
props:
- contextPath: /http
- appName: http
- port: 8188
- isFull: false
nacosNameSpace: ShenyuRegisterCenter
# registerType : 服务注册类型,填写 nacos
# serverList: 为nacos注册类型时,填写nacos地址,多个地址用英文逗号分隔
@@ -392,8 +397,46 @@ shenyu:
# appName:你的应用名称,不配置的话,会默认取 `spring.application.name` 的值
# isFull: 设置true
代表代理你的整个服务,false表示代理你其中某几个controller;目前适用于springmvc/springcloud
# nacosNameSpace: nacos的命名空间
-```
+```
<img src="/img/shenyu/register/register-nacos-client-yml.png" width="70%"
height="60%" />
+### 同时注册多种服务类型
+
+> 以同时注册http和dubbo服务举例。
+
+在`yml`参考如下配置即可:
+
+```yaml
+shenyu:
+ client:
+ registerType: nacos
+ serverLists: localhost:8848
+ http:
+ props:
+ contextPath: /http
+ appName: http
+ port: 8188
+ isFull: false
+ dubbo:
+ props:
+ contextPath: /dubbo
+ appName: dubbo
+ port: 28080
+ props:
+ nacosNameSpace: ShenyuRegisterCenter
+# registerType : 服务注册类型,填写 nacos
+# serverList: 为nacos注册类型时,填写nacos地址,多个地址用英文逗号分隔
+# http.port: 你本项目的启动Http端口,目前springmvc/SpringCloud需要进行填写
+# http.contextPath: 为你的这个mvc项目在shenyu网关的路由前缀,比如/order ,/product
等等,网关会根据你的这个前缀来进行路由.
+# http.appName:你的应用名称,不配置的话,会默认取 `spring.application.name` 的值
+# http.isFull: 设置true
代表代理你的整个服务,false表示代理你其中某几个controller;目前适用于springmvc/springcloud
+# dubbo.contextPath: 为你的项目中对应dubbo接口的contextPath
+# dubbo.port: dubbo服务端口
+# dubbo.appName: dubbo应用名称
+# nacosNameSpace: nacos的命名空间
+```
+
+
+
总结,本文主要介绍了如何将你的微服务(当前支持`Http`、 `Dubbo`、 `Spring Cloud`、 `gRPC`、 `Motan`、
`Sofa`、 `Tars`等协议)接入到`Apache ShenYu`网关。介绍了注册中心的原理,`Apache
ShenYu`网关支持的注册中心有`Http`、`Zookeeper`、`Etcd`、`Consul`、`Nacos`等方式。介绍了以`http`服务作为客户端接入到`Apache
ShenYu`网关时,使用不同方式注册配置信息。