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/10/24 07:40:34 UTC

[GitHub] [apisix] tzssangglass opened a new pull request, #8157: feat: renew route lrucache when the routes change

tzssangglass opened a new pull request, #8157:
URL: https://github.com/apache/apisix/pull/8157

   ### Description
   
   <!-- Please include a summary of the change and which issue is fixed. -->
   <!-- Please also include relevant motivation and context. -->
   
   Use the fix from #8119 and resolve the lrucache and router match loops.
   
   Fixes # (issue)
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [ ] I have updated the documentation to reflect this change
   - [x] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first)
   
   <!--
   
   Note
   
   1. Mark the PR as draft until it's ready to be reviewed.
   2. Always add/update tests for any changes unless you have a good reason.
   3. Always update the documentation to reflect the changes made in the PR.
   4. Make a new commit to resolve conversations instead of `push -f`.
   5. To resolve merge conflicts, merge master instead of rebasing.
   6. Use "request review" to notify the reviewer after making changes.
   7. Only a reviewer can mark a conversation as resolved.
   
   -->
   


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


[GitHub] [apisix] tzssangglass commented on a diff in pull request #8157: feat: renew route lrucache when the routes change

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on code in PR #8157:
URL: https://github.com/apache/apisix/pull/8157#discussion_r1003063385


##########
apisix/plugins/ai.lua:
##########
@@ -70,21 +67,20 @@ local orig_http_balancer_phase = apisix.http_balancer_phase
 
 local default_keepalive_pool = {}
 
-local function match_route(ctx)
-    orig_router_match(ctx)
-    return ctx.matched_route or false
+local function match_route(uri_router, match_opts, api_ctx)

Review Comment:
   done



##########
apisix/plugins/ai.lua:
##########
@@ -280,7 +281,8 @@ end
 
 
 function _M.init_worker()
-    orig_router_match = router.router_http.match
+    orig_router_match = base_router.match_uri

Review Comment:
   done



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


[GitHub] [apisix] tzssangglass commented on a diff in pull request #8157: feat: renew route lrucache when the routes change

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on code in PR #8157:
URL: https://github.com/apache/apisix/pull/8157#discussion_r1003063161


##########
apisix/plugins/ai.lua:
##########
@@ -224,15 +220,20 @@ local function routes_analyze(routes)
          or route_flags["service_id"]
          or route_flags["plugin_config_id"]
          or global_rules_flag then
-        router.router_http.match = orig_router_match
+            base_router.match_uri = orig_router_match
     else
         core.log.info("use ai plane to match route")
-        router.router_http.match = ai_match
+        base_router.match_uri = ai_match_uri
+        local count = #routes + 3000

Review Comment:
   done



##########
apisix/plugins/ai.lua:
##########
@@ -224,15 +220,20 @@ local function routes_analyze(routes)
          or route_flags["service_id"]
          or route_flags["plugin_config_id"]
          or global_rules_flag then
-        router.router_http.match = orig_router_match
+            base_router.match_uri = orig_router_match

Review Comment:
   done



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


[GitHub] [apisix] spacewander merged pull request #8157: feat: renew route lrucache when the routes change

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


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


[GitHub] [apisix] membphis commented on a diff in pull request #8157: feat: renew route lrucache when the routes change

Posted by GitBox <gi...@apache.org>.
membphis commented on code in PR #8157:
URL: https://github.com/apache/apisix/pull/8157#discussion_r1002968432


##########
apisix/plugins/ai.lua:
##########
@@ -280,7 +281,8 @@ end
 
 
 function _M.init_worker()
-    orig_router_match = router.router_http.match
+    orig_router_match = base_router.match_uri

Review Comment:
   we need a better name for `orig_router_match`



##########
apisix/plugins/ai.lua:
##########
@@ -70,21 +67,20 @@ local orig_http_balancer_phase = apisix.http_balancer_phase
 
 local default_keepalive_pool = {}
 
-local function match_route(ctx)
-    orig_router_match(ctx)
-    return ctx.matched_route or false
+local function match_route(uri_router, match_opts, api_ctx)

Review Comment:
   we need a better name: `match_route `



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


[GitHub] [apisix] membphis commented on a diff in pull request #8157: feat: renew route lrucache when the routes change

Posted by GitBox <gi...@apache.org>.
membphis commented on code in PR #8157:
URL: https://github.com/apache/apisix/pull/8157#discussion_r1002971335


##########
apisix/plugins/ai.lua:
##########
@@ -224,15 +220,20 @@ local function routes_analyze(routes)
          or route_flags["service_id"]
          or route_flags["plugin_config_id"]
          or global_rules_flag then
-        router.router_http.match = orig_router_match
+            base_router.match_uri = orig_router_match
     else
         core.log.info("use ai plane to match route")
-        router.router_http.match = ai_match
+        base_router.match_uri = ai_match_uri
+        local count = #routes + 3000

Review Comment:
   pls add one more blank line before this line



##########
apisix/plugins/ai.lua:
##########
@@ -224,15 +220,20 @@ local function routes_analyze(routes)
          or route_flags["service_id"]
          or route_flags["plugin_config_id"]
          or global_rules_flag then
-        router.router_http.match = orig_router_match
+            base_router.match_uri = orig_router_match

Review Comment:
   bad indentation



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