You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by to...@apache.org on 2021/05/24 09:42:03 UTC
[apisix] branch master updated: chore: sort plugin by priority and
recommend priority for custom plugin (#4292)
This is an automated email from the ASF dual-hosted git repository.
tokers pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new d6acd8d chore: sort plugin by priority and recommend priority for custom plugin (#4292)
d6acd8d is described below
commit d6acd8d56862e023503f02f5f6fc91ad3d2a852e
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Mon May 24 17:41:50 2021 +0800
chore: sort plugin by priority and recommend priority for custom plugin (#4292)
Signed-off-by: spacewander <sp...@gmail.com>
---
conf/config-default.yaml | 97 ++++++++++++++++++++--------------------
docs/en/latest/plugin-develop.md | 2 +-
docs/zh/latest/plugin-develop.md | 2 +-
t/core/config.t | 2 +-
4 files changed, 52 insertions(+), 51 deletions(-)
diff --git a/conf/config-default.yaml b/conf/config-default.yaml
index 45f9853..a48f916 100644
--- a/conf/config-default.yaml
+++ b/conf/config-default.yaml
@@ -235,54 +235,55 @@ graphql:
#ext-plugin:
#cmd: ["ls", "-l"]
-plugins: # plugin list (sorted in alphabetical order)
- - api-breaker
- - authz-keycloak
- - basic-auth
- - batch-requests
- - consumer-restriction
- - cors
- #- dubbo-proxy
- - echo
- #- error-log-logger
- #- example-plugin
- - ext-plugin-pre-req
- - ext-plugin-post-req
- - fault-injection
- - grpc-transcode
- - hmac-auth
- - http-logger
- - ip-restriction
- - jwt-auth
- - kafka-logger
- - key-auth
- - limit-conn
- - limit-count
- - limit-req
- #- log-rotate
- #- node-status
- - openid-connect
- - prometheus
- - proxy-cache
- - proxy-mirror
- - proxy-rewrite
- - redirect
- - referer-restriction
- - request-id
- - request-validation
- - response-rewrite
- - serverless-post-function
- - serverless-pre-function
- #- skywalking
- - sls-logger
- - syslog
- - tcp-logger
- - udp-logger
- - uri-blocker
- - wolf-rbac
- - zipkin
- - server-info
- - traffic-split
+plugins: # plugin list (sorted by priority)
+ - ext-plugin-pre-req # priority: 12000
+ - zipkin # priority: 11011
+ - request-id # priority: 11010
+ - fault-injection # priority: 11000
+ - serverless-pre-function # priority: 10000
+ - batch-requests # priority: 4010
+ - cors # priority: 4000
+ - ip-restriction # priority: 3000
+ - referer-restriction # priority: 2990
+ - uri-blocker # priority: 2900
+ - request-validation # priority: 2800
+ - openid-connect # priority: 2599
+ - wolf-rbac # priority: 2555
+ - hmac-auth # priority: 2530
+ - basic-auth # priority: 2520
+ - jwt-auth # priority: 2510
+ - key-auth # priority: 2500
+ - consumer-restriction # priority: 2400
+ - authz-keycloak # priority: 2000
+ #- error-log-logger # priority: 1091
+ - proxy-mirror # priority: 1010
+ - proxy-cache # priority: 1009
+ - proxy-rewrite # priority: 1008
+ - api-breaker # priority: 1005
+ - limit-conn # priority: 1003
+ - limit-count # priority: 1002
+ - limit-req # priority: 1001
+ #- node-status # priority: 1000
+ - server-info # priority: 990
+ - traffic-split # priority: 966
+ - redirect # priority: 900
+ - response-rewrite # priority: 899
+ #- dubbo-proxy # priority: 507
+ - grpc-transcode # priority: 506
+ - prometheus # priority: 500
+ - echo # priority: 412
+ - http-logger # priority: 410
+ - sls-logger # priority: 406
+ - tcp-logger # priority: 405
+ - kafka-logger # priority: 403
+ - syslog # priority: 401
+ - udp-logger # priority: 400
+ #- log-rotate # priority: 100
+ # <- recommend to use priority (0, 100) for your custom plugins
+ - example-plugin # priority: 0
+ #- skywalking # priority: -1100
+ - serverless-post-function # priority: -2000
+ - ext-plugin-post-req # priority: -3000
stream_plugins:
- mqtt-proxy
diff --git a/docs/en/latest/plugin-develop.md b/docs/en/latest/plugin-develop.md
index 67535a4..df072c0 100644
--- a/docs/en/latest/plugin-develop.md
+++ b/docs/en/latest/plugin-develop.md
@@ -107,7 +107,7 @@ local _M = {
}
```
-Note : The priority of the new plugin cannot be same to any existing ones, you can use the `/v1/schema` method of [control API](./control-api.md#get-v1schema) to view the priority of all plugins. In addition, plugins with higher priority value will be executed first in a given phase (see the definition of `phase` in [choose-phase-to-run](#choose-phase-to-run)). For example, the priority of example-plugin is 0 and the priority of ip-restriction is 3000. Therefore, the ip-restriction plugi [...]
+Note : The priority of the new plugin cannot be same to any existing ones, you can use the `/v1/schema` method of [control API](./control-api.md#get-v1schema) to view the priority of all plugins. In addition, plugins with higher priority value will be executed first in a given phase (see the definition of `phase` in [choose-phase-to-run](#choose-phase-to-run)). For example, the priority of example-plugin is 0 and the priority of ip-restriction is 3000. Therefore, the ip-restriction plugi [...]
in the "__conf/config-default.yaml__" configuration file, the enabled plugins (all specified by plugin name) are listed.
diff --git a/docs/zh/latest/plugin-develop.md b/docs/zh/latest/plugin-develop.md
index f450bf1..63b54f4 100644
--- a/docs/zh/latest/plugin-develop.md
+++ b/docs/zh/latest/plugin-develop.md
@@ -73,7 +73,7 @@ local _M = {
}
```
-注:新插件的优先级( priority 属性 )不能与现有插件的优先级相同,您可以使用 [control API](../../en/latest/control-api.md#get-v1schema) 的 `/v1/schema` 方法查看所有插件的优先级。另外,同一个阶段里面,优先级( priority )值大的插件,会优先执行,比如 `example-plugin` 的优先级是 0 ,`ip-restriction` 的优先级是 3000 ,所以在每个阶段,会先执行 `ip-restriction` 插件,再去执行 `example-plugin` 插件。这里的“阶段”的定义,参见后续的[确定执行阶段](#确定执行阶段)这一节。
+注:新插件的优先级( priority 属性 )不能与现有插件的优先级相同,您可以使用 [control API](../../en/latest/control-api.md#get-v1schema) 的 `/v1/schema` 方法查看所有插件的优先级。另外,同一个阶段里面,优先级( priority )值大的插件,会优先执行,比如 `example-plugin` 的优先级是 0 ,`ip-restriction` 的优先级是 3000 ,所以在每个阶段,会先执行 `ip-restriction` 插件,再去执行 `example-plugin` 插件。这里的“阶段”的定义,参见后续的[确定执行阶段](#确定执行阶段)这一节。对于你的插件,建议采用 1 到 99 之间的优先级。
在 __conf/config-default.yaml__ 配置文件中,列出了启用的插件(都是以插件名指定的):
diff --git a/t/core/config.t b/t/core/config.t
index a8e998e..d5cc0f4 100644
--- a/t/core/config.t
+++ b/t/core/config.t
@@ -38,7 +38,7 @@ __DATA__
GET /t
--- response_body
etcd host: http://127.0.0.1:2379
-first plugin: "api-breaker"
+first plugin: "ext-plugin-pre-req"