You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/06/17 11:53:48 UTC

[GitHub] [apisix] nfrankel commented on a diff in pull request #7273: feat: allows users to specify plugin execution priority

nfrankel commented on code in PR #7273:
URL: https://github.com/apache/apisix/pull/7273#discussion_r900037306


##########
docs/en/latest/terminology/plugin.md:
##########
@@ -95,6 +95,43 @@ the configuration above means customizing the error response from the jwt-auth p
 | Name         | Type | Description |
 |--------------|------|-------------|
 | error_response | string/object  | Custom error response |
+| priority       | integer        | Custom plugin priority |
+
+### Custom Plugin Priority
+
+All plugins have a default priority, but it is possible to customize the plugin priority to change the plugin's execution order.
+
+```json
+ {
+    "serverless-post-function": {
+        "_meta": {

Review Comment:
   As I already mentioned, this is poor Developer Experience. It makes the use of the configuration more complex for no reason except that it's easier to implement.



##########
docs/en/latest/terminology/plugin.md:
##########
@@ -95,6 +95,43 @@ the configuration above means customizing the error response from the jwt-auth p
 | Name         | Type | Description |
 |--------------|------|-------------|
 | error_response | string/object  | Custom error response |
+| priority       | integer        | Custom plugin priority |
+
+### Custom Plugin Priority
+
+All plugins have a default priority, but it is possible to customize the plugin priority to change the plugin's execution order.
+
+```json
+ {
+    "serverless-post-function": {
+        "_meta": {
+            "priority": 10000
+        },
+        "phase": "rewrite",
+        "functions" : ["return function(conf, ctx)
+                    ngx.say(\"serverless-post-function\");
+                    end"]
+    },
+    "serverless-pre-function": {
+        "_meta": {
+            "priority": -2000
+        },
+        "phase": "rewrite",
+        "functions": ["return function(conf, ctx)
+                    ngx.say(\"serverless-pre-function\");
+                    end"]
+    }
+}
+```
+
+The default priority of serverless-pre-function is 10000, and the default priority of serverless-post-function is -2000. By default, the serverless-pre-function plugin will be executed first, and serverless-post-function plugin will be executed next.

Review Comment:
   At this point, why do we keep two different functions? We can keep a single one as call it whenever we required it. Can we change the sample?



##########
docs/en/latest/terminology/plugin.md:
##########
@@ -95,6 +95,43 @@ the configuration above means customizing the error response from the jwt-auth p
 | Name         | Type | Description |
 |--------------|------|-------------|
 | error_response | string/object  | Custom error response |
+| priority       | integer        | Custom plugin priority |
+
+### Custom Plugin Priority
+
+All plugins have a default priority, but it is possible to customize the plugin priority to change the plugin's execution order.
+
+```json
+ {
+    "serverless-post-function": {
+        "_meta": {
+            "priority": 10000
+        },
+        "phase": "rewrite",
+        "functions" : ["return function(conf, ctx)
+                    ngx.say(\"serverless-post-function\");
+                    end"]
+    },
+    "serverless-pre-function": {
+        "_meta": {
+            "priority": -2000
+        },
+        "phase": "rewrite",
+        "functions": ["return function(conf, ctx)
+                    ngx.say(\"serverless-pre-function\");
+                    end"]
+    }
+}
+```
+
+The default priority of serverless-pre-function is 10000, and the default priority of serverless-post-function is -2000. By default, the serverless-pre-function plugin will be executed first, and serverless-post-function plugin will be executed next.

Review Comment:
   A good use-case would be the combination of `proxy-mirror` plugin and the `proxy-rewrite` one.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

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