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 2021/05/05 08:53:56 UTC

[GitHub] [apisix] spacewander opened a new pull request #4183: feat(ext-plugin): implement the http-req-call protocol

spacewander opened a new pull request #4183:
URL: https://github.com/apache/apisix/pull/4183


   Signed-off-by: spacewander <sp...@gmail.com>
   
   ### What this PR does / why we need it:
   <!--- Why is this change required? What problem does it solve? -->
   <!--- If it fixes an open issue, please link to the issue here. -->
   
   ### Pre-submission checklist:
   
   * [x] Did you explain what problem does this PR solve? Or what new features have been added?
   * [x] Have you added corresponding test cases?
   * [ ] Have you modified the corresponding document?
   * [ ] Is this PR backward compatible? **If it is not backward compatible, please discuss on the [mailing list](https://github.com/apache/apisix/tree/master#community) first**
   


-- 
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:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on a change in pull request #4183: feat(ext-plugin): implement the http-req-call protocol

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #4183:
URL: https://github.com/apache/apisix/pull/4183#discussion_r627021530



##########
File path: apisix/plugins/ext-plugin/init.lua
##########
@@ -152,6 +165,80 @@ end
 _M.receive = receive
 
 
+local generate_id
+do
+    local count = 0
+    local MAX_COUNT = lshift(1, 22)
+
+    function generate_id()
+        local wid = worker_id()
+        local id = lshift(wid, 22) + count
+        count = count + 1
+        if count == MAX_COUNT then
+            count = 0
+        end
+        return id
+    end
+end
+
+
+local encode_a6_method
+do
+    local map = {
+        GET = a6_method.GET,
+        HEAD = a6_method.HEAD,
+        POST = a6_method.POST,
+        PUT = a6_method.PUT,
+        DELETE = a6_method.DELETE,
+        MKCOL = a6_method.MKCOL,
+        COPY = a6_method.COPY,
+        MOVE = a6_method.MOVE,
+        OPTIONS = a6_method.OPTIONS,
+        PROPFIND = a6_method.PROPFIND,
+        PROPPATCH = a6_method.PROPPATCH,
+        LOCK = a6_method.LOCK,
+        UNLOCK = a6_method.UNLOCK,

Review comment:
       Those fields are copied from https://github.com/openresty/lua-nginx-module#http-method-constants




-- 
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:
users@infra.apache.org



[GitHub] [apisix] membphis commented on a change in pull request #4183: feat(ext-plugin): implement the http-req-call protocol

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #4183:
URL: https://github.com/apache/apisix/pull/4183#discussion_r626530037



##########
File path: apisix/plugins/ext-plugin/init.lua
##########
@@ -152,6 +165,80 @@ end
 _M.receive = receive
 
 
+local generate_id
+do
+    local count = 0
+    local MAX_COUNT = lshift(1, 22)
+
+    function generate_id()
+        local wid = worker_id()
+        local id = lshift(wid, 22) + count
+        count = count + 1
+        if count == MAX_COUNT then
+            count = 0
+        end
+        return id
+    end
+end
+
+
+local encode_a6_method
+do
+    local map = {
+        GET = a6_method.GET,
+        HEAD = a6_method.HEAD,
+        POST = a6_method.POST,
+        PUT = a6_method.PUT,
+        DELETE = a6_method.DELETE,
+        MKCOL = a6_method.MKCOL,
+        COPY = a6_method.COPY,
+        MOVE = a6_method.MOVE,
+        OPTIONS = a6_method.OPTIONS,
+        PROPFIND = a6_method.PROPFIND,
+        PROPPATCH = a6_method.PROPPATCH,
+        LOCK = a6_method.LOCK,
+        UNLOCK = a6_method.UNLOCK,

Review comment:
       Is this type reserved for the future? If yes, is there any documentation?




-- 
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:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on a change in pull request #4183: feat(ext-plugin): implement the http-req-call protocol

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #4183:
URL: https://github.com/apache/apisix/pull/4183#discussion_r627025578



##########
File path: apisix/plugins/ext-plugin/init.lua
##########
@@ -152,6 +165,80 @@ end
 _M.receive = receive
 
 
+local generate_id
+do
+    local count = 0
+    local MAX_COUNT = lshift(1, 22)
+
+    function generate_id()
+        local wid = worker_id()
+        local id = lshift(wid, 22) + count
+        count = count + 1
+        if count == MAX_COUNT then
+            count = 0

Review comment:
       The id here is only used for logging purpose. In the given time window, it is rare to have two repeated id so we can distinguish them.




-- 
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:
users@infra.apache.org



[GitHub] [apisix] spacewander merged pull request #4183: feat(ext-plugin): implement the http-req-call protocol

Posted by GitBox <gi...@apache.org>.
spacewander merged pull request #4183:
URL: https://github.com/apache/apisix/pull/4183


   


-- 
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:
users@infra.apache.org



[GitHub] [apisix] tokers commented on a change in pull request #4183: feat(ext-plugin): implement the http-req-call protocol

Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #4183:
URL: https://github.com/apache/apisix/pull/4183#discussion_r627021898



##########
File path: apisix/plugins/ext-plugin/init.lua
##########
@@ -152,6 +165,80 @@ end
 _M.receive = receive
 
 
+local generate_id
+do
+    local count = 0
+    local MAX_COUNT = lshift(1, 22)
+
+    function generate_id()
+        local wid = worker_id()
+        local id = lshift(wid, 22) + count
+        count = count + 1
+        if count == MAX_COUNT then
+            count = 0

Review comment:
       Does the id rotate will influence the correctness?




-- 
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:
users@infra.apache.org



[GitHub] [apisix] tokers commented on a change in pull request #4183: feat(ext-plugin): implement the http-req-call protocol

Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #4183:
URL: https://github.com/apache/apisix/pull/4183#discussion_r627025839



##########
File path: apisix/plugins/ext-plugin/init.lua
##########
@@ -152,6 +165,80 @@ end
 _M.receive = receive
 
 
+local generate_id
+do
+    local count = 0
+    local MAX_COUNT = lshift(1, 22)
+
+    function generate_id()
+        local wid = worker_id()
+        local id = lshift(wid, 22) + count
+        count = count + 1
+        if count == MAX_COUNT then
+            count = 0

Review comment:
       OK.




-- 
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:
users@infra.apache.org



[GitHub] [apisix] membphis commented on a change in pull request #4183: feat(ext-plugin): implement the http-req-call protocol

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #4183:
URL: https://github.com/apache/apisix/pull/4183#discussion_r627022066



##########
File path: apisix/plugins/ext-plugin/init.lua
##########
@@ -152,6 +165,80 @@ end
 _M.receive = receive
 
 
+local generate_id
+do
+    local count = 0
+    local MAX_COUNT = lshift(1, 22)
+
+    function generate_id()
+        local wid = worker_id()
+        local id = lshift(wid, 22) + count
+        count = count + 1
+        if count == MAX_COUNT then
+            count = 0
+        end
+        return id
+    end
+end
+
+
+local encode_a6_method
+do
+    local map = {
+        GET = a6_method.GET,
+        HEAD = a6_method.HEAD,
+        POST = a6_method.POST,
+        PUT = a6_method.PUT,
+        DELETE = a6_method.DELETE,
+        MKCOL = a6_method.MKCOL,
+        COPY = a6_method.COPY,
+        MOVE = a6_method.MOVE,
+        OPTIONS = a6_method.OPTIONS,
+        PROPFIND = a6_method.PROPFIND,
+        PROPPATCH = a6_method.PROPPATCH,
+        LOCK = a6_method.LOCK,
+        UNLOCK = a6_method.UNLOCK,

Review comment:
       got it, many thanks for explaining




-- 
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:
users@infra.apache.org