liubao68 closed pull request #4: 增加URLMappedEdgeDispatcher的文档说明
URL: https://github.com/apache/incubator-servicecomb-docs/pull/4
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/java-chassis-reference/zh_CN/edge/by-servicecomb-sdk.md 
b/java-chassis-reference/zh_CN/edge/by-servicecomb-sdk.md
index 816df59..bda6b16 100644
--- a/java-chassis-reference/zh_CN/edge/by-servicecomb-sdk.md
+++ b/java-chassis-reference/zh_CN/edge/by-servicecomb-sdk.md
@@ -76,16 +76,16 @@ servicecomb:
           enabled: true
           prefix: rest
           withVersion: true
-          pathIndex: 2
+          prefixSegmentCount: 1
 ```
 
 常见的这些配置项的示例及含义如下:
-* [prefix=rest;withVersion=true;pathIndex=2]微服务xService提供的URL为: 
/xService/v1/abc,通过Edge访问的地址为/rest/xService/v1/abc,请求只转发到[1.0.0-2.0.0)版本的微服务实例。
-* [prefix=rest;withVersion=true;pathIndex=3]微服务xService提供的URL为: 
/v1/abc,通过Edge访问的地址为/rest/xService/v1/abc,请求只转发到[1.0.0-2.0.0)版本的微服务实例。
-* [prefix=rest;withVersion=true;pathIndex=4]微服务xService提供的URL为: 
/abc,通过Edge访问的地址为/rest/xService/v1/abc,请求只转发到[1.0.0-2.0.0)版本的微服务实例。
-* [prefix=rest;withVersion=false;pathIndex=2]微服务xService提供的URL为: 
/xService/v1/abc,通过Edge访问的地址为/rest/xService/v1/abc,请求可能转发到任意微服务实例。
-* [prefix=rest;withVersion=false;pathIndex=3]微服务xService提供的URL为: 
/v1/abc,通过Edge访问的地址为/rest/xService/v1/abc,,请求可能转发到任意微服务实例。
-* [prefix=rest;withVersion=false;pathIndex=3]微服务xService提供的URL为: 
/abc,通过Edge访问的地址为/rest/xService/abc,,请求可能转发到任意微服务实例。
+* [prefix=rest;withVersion=true;prefixSegmentCount=1]微服务xService提供的URL为: 
/xService/v1/abc,通过Edge访问的地址为/rest/xService/v1/abc,请求只转发到[1.0.0-2.0.0)版本的微服务实例。
+* [prefix=rest;withVersion=true;prefixSegmentCount=2]微服务xService提供的URL为: 
/v1/abc,通过Edge访问的地址为/rest/xService/v1/abc,请求只转发到[1.0.0-2.0.0)版本的微服务实例。
+* [prefix=rest;withVersion=true;prefixSegmentCount=3]微服务xService提供的URL为: 
/abc,通过Edge访问的地址为/rest/xService/v1/abc,请求只转发到[1.0.0-2.0.0)版本的微服务实例。
+* [prefix=rest;withVersion=false;prefixSegmentCount=1]微服务xService提供的URL为: 
/xService/v1/abc,通过Edge访问的地址为/rest/xService/v1/abc,请求可能转发到任意微服务实例。
+* [prefix=rest;withVersion=false;prefixSegmentCount=2]微服务xService提供的URL为: 
/v1/abc,通过Edge访问的地址为/rest/xService/v1/abc,,请求可能转发到任意微服务实例。
+* [prefix=rest;withVersion=false;prefixSegmentCount=2]微服务xService提供的URL为: 
/abc,通过Edge访问的地址为/rest/xService/abc,,请求可能转发到任意微服务实例。
 
 withVersion配置项提供了客户端灰度规则,可以让客户端指定访问的服务端版本。Edge 
Service还包含根据接口兼容性自动路由的功能,请求会转发到包含了该接口的实例。假设某微服务,兼容规划为所有高版本必须兼容低版本,部署了以下版本实例:
 
@@ -99,6 +99,32 @@ Edge Service在转发operation2时,会自动使用1.1.0+的规则来过滤实
 
 以上过程用户不必做任何干预,全自动完成,以避免将新版本的operation转发到旧版本的实例中去。
 
+### 使用URLMappedEdgeDispatcher
+URLMappedEdgeDispatcher允许用户配置URL和微服务的映射关系。使用它可以非常灵活的定义哪些URL转发到哪些微服务。它包含如下几个配置项:
+```
+servicecomb:
+  http:
+    dispatcher:
+      edge:
+        url:
+          enabled: true
+          mappings:
+            businessV1:
+              prefixSegmentCount: 1
+              path: "/url/business/v1/.*"
+              microserviceName: business
+              versionRule: 1.0.0-2.0.0
+            businessV2:
+              prefixSegmentCount: 1
+              path: "/url/business/v2/.*"
+              microserviceName: business
+              versionRule: 2.0.0-3.0.0
+```
+
+businessV1配置项表示的含义是将请求路径为/usr/business/v1/.*的请求,转发到business这个微服务,并且只转发到版本号为1.0.0-2.0.0的实例(不含2.0.0)。转发的时候URL为/business/v1/.*。path使用的是JDK的正则表达式,可以查看Pattern类的说明。prefixSegmentCount表示前缀的URL
 
Segment数量,前缀不包含在转发的URL路径中。有三种形式的versionRule可以指定。2.0.0-3.0.0表示版本范围,含2.0.0,但不含3.0.0;2.0.0+表示大于2.0.0的版本,含2.0.0;2.0.0表示只转发到2.0.0版本。2,2.0等价于2.0.0。
+
+从上面的配置可以看出,URLMappedEdgeDispatcher也支持客户端灰度。当然配置项会比DefaultEdgeDispatcher多。URLMappedEdgeDispatcher支持通过配置中心动态的修改配置,调整路由规则。
+
 ### 自定义Dispatcher
 
 自定义Dispatcher包含两个步骤:
diff --git a/java-chassis-reference/zh_CN/styles/website.css 
b/java-chassis-reference/zh_CN/styles/website.css
new file mode 100644
index 0000000..815fe4b
--- /dev/null
+++ b/java-chassis-reference/zh_CN/styles/website.css
@@ -0,0 +1,5 @@
+table {
+    table-layout: fixed;
+    display:block;
+    overflow-x: auto;
+}
\ No newline at end of file


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to