membphis commented on a change in pull request #2339:
URL: https://github.com/apache/apisix/pull/2339#discussion_r502743189



##########
File path: doc/plugins/api-breaker.md
##########
@@ -0,0 +1,106 @@
+<!--
+#
+# 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.
+#
+-->
+
+- [中文](../zh-cn/plugins/api-blocker.md)
+
+# Summary
+
+- [**Name**](#name)
+- [**Attributes**](#attributes)
+- [**How To Enable**](#how-to-enable)
+- [**Test Plugin**](#test-plugin)
+- [**Disable Plugin**](#disable-plugin)
+
+## Name
+
+The plugin implements API fuse functionality to help us protect our upstream 
business services.
+
+About the breaker timeout logic; the current version does not open the 
relevant configuration items to the user, the code logic automatically 
**triggers the unhealthy state **incrementation of the number of operations.

Review comment:
       I think we should use `:` here

##########
File path: doc/zh-cn/plugins/api-breaker.md
##########
@@ -0,0 +1,107 @@
+<!--
+#
+# 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.
+#
+-->
+
+- [English](../../plugins/api-blocker.md)
+
+# 目录
+
+- [**定义**](#定义)
+- [**属性列表**](#属性列表)
+- [**启用方式**](#启用方式)
+- [**测试插件**](#测试插件)
+- [**禁用插件**](#禁用插件)
+
+## 定义
+
+该插件实现API熔断功能,帮助我们保护上游业务服务。
+
+关于熔断超时逻辑;当前版本没有开放相关配置项给用户,由代码逻辑自动按**触发不健康状态**的次数递增运算。
+
+比如:上流服务第一次返回`unhealthy.http_statuses`状态达到`unhealthy.failures`次时,**熔断2秒**。然后,过2秒以后,上流服务再次连续返回`unhealthy.http_statuses`状态达到`unhealthy.failures`次时,**熔断4秒**。依次类推,最大达到300秒不再增加。

Review comment:
       show more step information ^_^
   help the user to understand it

##########
File path: doc/zh-cn/plugins/api-breaker.md
##########
@@ -0,0 +1,107 @@
+<!--
+#
+# 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.
+#
+-->
+
+- [English](../../plugins/api-blocker.md)
+
+# 目录
+
+- [**定义**](#定义)
+- [**属性列表**](#属性列表)
+- [**启用方式**](#启用方式)
+- [**测试插件**](#测试插件)
+- [**禁用插件**](#禁用插件)
+
+## 定义
+
+该插件实现API熔断功能,帮助我们保护上游业务服务。
+
+关于熔断超时逻辑;当前版本没有开放相关配置项给用户,由代码逻辑自动按**触发不健康状态**的次数递增运算。
+
+比如:上流服务第一次返回`unhealthy.http_statuses`状态达到`unhealthy.failures`次时,**熔断2秒**。然后,过2秒以后,上流服务再次连续返回`unhealthy.http_statuses`状态达到`unhealthy.failures`次时,**熔断4秒**。依次类推,最大达到300秒不再增加。
+
+
+## 属性列表
+
+| 名称                    | 类型           | 必选项 | 默认值     | 有效值          | 描述     
                        |
+| ----------------------- | -------------- | ------ | ---------- | 
--------------- | -------------------------------- |
+| unhealthy_response_code | integer        | 必须   | 无         | [200, ..., 
600] | 不健康返回错误码                 |
+| unhealthy.http_statuses | array[integer] | 可选   | {500}      | [500, ..., 
599] | 不健康时候的状态码               |
+| unhealthy.failures      | integer        | 可选   | 1          | >=1           
  | 触发不健康状态的连续错误请求次数 |
+| healthy.http_statuses   | array[integer] | 可选   | {200, 206} | [200, ..., 
499] | 健康时候的状态码                 |
+| successes.successes     | integer        | 可选   | 1          | >=1           
  | 触发健康状态的连续正常请求次数   |
+
+## 启用方式
+
+这是一个示例,在指定的路由上启用`api-breaker`插件:
+
+```shell
+curl "http://127.0.0.1:9080/apisix/admin/routes/5"; -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+   {
+      "plugins": {
+          "api-breaker": {
+              "unhealthy_response_code": 502,
+              "unhealthy": {
+                  "http_statuses": [500, 503],
+                  "failures": 3
+              },
+              "healthy": {
+                  "http_statuses": [200],
+                  "successes": 1
+              }
+          }
+      },
+      "uri": "/get",
+      "host": "127.0.0.1",
+      "upstream_id": 50
+  }'
+```
+
+## 测试插件
+
+```shell
+$ curl -i -X POST "http://127.0.0.1:9080/get";
+HTTP/1.1 502 Bad Gateway
+Content-Type: application/octet-stream
+Connection: keep-alive
+Server: APISIX/1.5
+
+... ...
+```
+
+> 然后。像上面的配置,如果你的上流服务返回500,连续3次。客户端将会收到502(unhealthy_response_code)应答。
+
+
+## 禁用插件
+
+当想禁用`api-breaker`插件时,非常简单,只需要在插件配置中删除相应的 json 配置,无需重启服务,即可立即生效:
+
+```shell
+curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+    "uri": "/*",

Review comment:
       it should be the same as 
https://github.com/apache/apisix/pull/2339/files#diff-9eaeaaf55eabada0eba200cbda40c43eR69

##########
File path: doc/zh-cn/plugins/api-breaker.md
##########
@@ -0,0 +1,107 @@
+<!--
+#
+# 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.
+#
+-->
+
+- [English](../../plugins/api-blocker.md)
+
+# 目录
+
+- [**定义**](#定义)
+- [**属性列表**](#属性列表)
+- [**启用方式**](#启用方式)
+- [**测试插件**](#测试插件)
+- [**禁用插件**](#禁用插件)
+
+## 定义
+
+该插件实现API熔断功能,帮助我们保护上游业务服务。

Review comment:
       need one space between Chinese and English

##########
File path: doc/zh-cn/plugins/api-breaker.md
##########
@@ -0,0 +1,107 @@
+<!--
+#
+# 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.
+#
+-->
+
+- [English](../../plugins/api-blocker.md)
+
+# 目录
+
+- [**定义**](#定义)
+- [**属性列表**](#属性列表)
+- [**启用方式**](#启用方式)
+- [**测试插件**](#测试插件)
+- [**禁用插件**](#禁用插件)
+
+## 定义
+
+该插件实现API熔断功能,帮助我们保护上游业务服务。
+
+关于熔断超时逻辑;当前版本没有开放相关配置项给用户,由代码逻辑自动按**触发不健康状态**的次数递增运算。
+
+比如:上流服务第一次返回`unhealthy.http_statuses`状态达到`unhealthy.failures`次时,**熔断2秒**。然后,过2秒以后,上流服务再次连续返回`unhealthy.http_statuses`状态达到`unhealthy.failures`次时,**熔断4秒**。依次类推,最大达到300秒不再增加。
+
+
+## 属性列表
+
+| 名称                    | 类型           | 必选项 | 默认值     | 有效值          | 描述     
                        |
+| ----------------------- | -------------- | ------ | ---------- | 
--------------- | -------------------------------- |
+| unhealthy_response_code | integer        | 必须   | 无         | [200, ..., 
600] | 不健康返回错误码                 |
+| unhealthy.http_statuses | array[integer] | 可选   | {500}      | [500, ..., 
599] | 不健康时候的状态码               |
+| unhealthy.failures      | integer        | 可选   | 1          | >=1           
  | 触发不健康状态的连续错误请求次数 |
+| healthy.http_statuses   | array[integer] | 可选   | {200, 206} | [200, ..., 
499] | 健康时候的状态码                 |
+| successes.successes     | integer        | 可选   | 1          | >=1           
  | 触发健康状态的连续正常请求次数   |
+
+## 启用方式
+
+这是一个示例,在指定的路由上启用`api-breaker`插件:
+
+```shell
+curl "http://127.0.0.1:9080/apisix/admin/routes/5"; -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+   {
+      "plugins": {
+          "api-breaker": {
+              "unhealthy_response_code": 502,
+              "unhealthy": {
+                  "http_statuses": [500, 503],
+                  "failures": 3
+              },
+              "healthy": {
+                  "http_statuses": [200],
+                  "successes": 1
+              }
+          }
+      },
+      "uri": "/get",
+      "host": "127.0.0.1",
+      "upstream_id": 50
+  }'
+```
+
+## 测试插件
+
+```shell

Review comment:
       need a simple description for this case.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to