spacewander commented on a change in pull request #3363:
URL: https://github.com/apache/apisix/pull/3363#discussion_r563557591



##########
File path: apisix/plugins/fault-injection.lua
##########
@@ -15,13 +15,66 @@
 -- limitations under the License.
 --
 local core = require("apisix.core")
+local expr = require("resty.expr.v1")
 
 local sleep = core.sleep
 local random = math.random
+local ipairs = ipairs
 
 local plugin_name   = "fault-injection"
 
 
+local vars_schema = {

Review comment:
       No, you don't remove it.

##########
File path: apisix/plugins/fault-injection.lua
##########
@@ -64,6 +119,25 @@ local function sample_hit(percentage)
 end
 
 
+local function vars_match(vars, ctx)
+    local match_result
+    for _, var in ipairs(vars) do
+        local expr, err = expr.new(var)
+        if err then
+            core.log.error("vars expression does not match: ", err)
+            return nil, err
+        end
+
+        match_result = expr:eval(ctx.var)
+        if match_result then
+            break
+        end
+    end
+
+    return match_result, nil
+end
+
+
 function _M.check_schema(conf)
     local ok, err = core.schema.check(schema, conf)

Review comment:
       No, I mean checking the expression via:
   ```lua
           local expr, err = expr.new(var)
           if err then
               core.log.error("failed to create vars expression: ", err)
               return nil, err
           end
   ```




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


Reply via email to