bzp2010 commented on code in PR #12465:
URL: https://github.com/apache/apisix/pull/12465#discussion_r2252928233
##########
apisix/plugins/workflow.lua:
##########
@@ -143,12 +154,14 @@ end
function _M.access(conf, ctx)
- for _, rule in ipairs(conf.rules) do
+ ctx._workflow_cache = ctx._workflow_cache or {}
+ for idx, rule in ipairs(conf.rules) do
local match_result = true
if rule.case then
- local expr, _ = expr.new(rule.case)
+ local expr = rule.__expr
Review Comment:
Need a check to assert that `__expr` must exist.
##########
apisix/plugins/workflow.lua:
##########
@@ -116,10 +120,17 @@ function _M.check_schema(conf)
for idx, rule in ipairs(conf.rules) do
if rule.case then
- local ok, err = expr.new(rule.case)
+ local expr, err = expr.new(rule.case)
if not ok then
return false, "failed to validate the 'case' expression: " ..
err
end
+ local mt = getmetatable(rule)
+ if not mt then
+ mt = {}
+ mt.__index = mt
Review Comment:
```suggestion
mt = {
__index = mt
}
```
##########
apisix/plugins/workflow.lua:
##########
@@ -157,5 +170,18 @@ function _M.access(conf, ctx)
end
end
+function _M.log(conf, ctx)
+ for idx, rule in ipairs(conf.rules) do
+ local match_result = ctx._workflow_cache[idx]
+ if match_result then
+ -- only one action is currently supported
+ local action = rule.actions[1]
+ local log_handler = support_action[action[1]].log_handler
+ if log_handler then
Review Comment:
This if seems to be useless? We can directly return nil to the plugin
framework?
--
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]