Baoyuantop commented on code in PR #12826:
URL: https://github.com/apache/apisix/pull/12826#discussion_r2639048938
##########
apisix/router.lua:
##########
@@ -17,33 +17,130 @@
local require = require
local http_route = require("apisix.http.route")
local apisix_upstream = require("apisix.upstream")
-local core = require("apisix.core")
+local core = require("apisix.core")
local set_plugins_meta_parent =
require("apisix.plugin").set_plugins_meta_parent
local str_lower = string.lower
-local ipairs = ipairs
+local ipairs = ipairs
+local process = require("ngx.process")
+
local _M = {version = 0.3}
-local function filter(route)
+_M.need_create_radixtree = true
+
+
+local function sync_tb_create(sync_tb, route)
+ if not sync_tb[route.value.id] then
+ sync_tb[route.value.id] = {op = "create", cur_route = route}
+ elseif sync_tb[route.value.id]["op"] == "delete" then
+ sync_tb[route.value.id] = {op = "update", cur_route = route,
+ last_route =
sync_tb[route.value.id]["last_route"]}
+ end
+end
+
+
+local function sync_tb_delete(sync_tb, route)
+ local key = route.value.id
+ if not sync_tb[key] then
+ sync_tb[key] = {op = "delete", last_route = route}
+ elseif sync_tb[key]["op"] == "create" then
+ sync_tb[key] = nil
+ elseif sync_tb[key]["op"] == "update" then
+ sync_tb[key] = {op = "delete", last_route = sync_tb[key]["last_route"]}
+ end
+end
+
+
+local function sync_tb_update(sync_tb, pre_route, route)
Review Comment:
```suggestion
local function sync_tb_update(sync_tb, pre_route, route)
```
##########
apisix/http/router/radixtree_host_uri.lua:
##########
@@ -34,8 +35,23 @@ local only_uri_router
local _M = {version = 0.1}
-local function push_host_router(route, host_routes, only_uri_routes)
- if type(route) ~= "table" then
+local function get_host_radixtree_route(host_rev, sub_router)
+ return {
+ id = host_rev,
+ paths = host_rev,
+ sub_router = sub_router,
+ filter_fun = function(vars, opts, ...)
+ return sub_router:dispatch(vars.uri, opts, ...)
+ end,
+ handler = function (api_ctx, match_opts)
+ api_ctx.real_curr_req_matched_host = match_opts.matched._path
+ end
+ }
+end
+
+
+local function push_host_router(route, host_routes, only_uri_routes, mode)
+ if route == nil or (type(route) ~= "table" or route.value == nil) then
Review Comment:
```suggestion
if route == nil or (type(route) ~= "table" or route.value == nil) then
```
##########
apisix/http/router/radixtree_host_uri.lua:
##########
@@ -34,8 +35,23 @@ local only_uri_router
local _M = {version = 0.1}
-local function push_host_router(route, host_routes, only_uri_routes)
- if type(route) ~= "table" then
+local function get_host_radixtree_route(host_rev, sub_router)
+ return {
+ id = host_rev,
+ paths = host_rev,
+ sub_router = sub_router,
+ filter_fun = function(vars, opts, ...)
+ return sub_router:dispatch(vars.uri, opts, ...)
+ end,
+ handler = function (api_ctx, match_opts)
+ api_ctx.real_curr_req_matched_host = match_opts.matched._path
+ end
+ }
+end
+
+
+local function push_host_router(route, host_routes, only_uri_routes, mode)
Review Comment:
What is the meaning of the `mode` parameter? It's not used in the function.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]