membphis commented on code in PR #12977:
URL: https://github.com/apache/apisix/pull/12977#discussion_r2772463576
##########
apisix/plugins/limit-count/init.lua:
##########
@@ -180,51 +210,34 @@ function _M.check_schema(conf, schema_type)
end
end
- return true
-end
-
-
-local function create_limit_obj(conf, ctx, plugin_name)
- core.log.info("create new " .. plugin_name .. " plugin instance")
-
- local count = conf.count
- if type(count) == "string" then
- local err, _
- count, err, _ = core.utils.resolve_var(count, ctx.var)
- if err then
- return nil, "could not resolve vars in count: " .. err
- end
- count = tonumber(count)
- if not count then
- return nil, "resolved count is not a number: " .. tostring(count)
+ local keys = {}
+ for _, rule in ipairs(conf.rules or {}) do
+ if keys[rule.key] then
+ return false, str_format("duplicate key '%s' in rules", rule.key)
end
+ keys[rule.key] = true
end
- local time_window = conf.time_window
- if type(time_window) == "string" then
- local err, _
- time_window, err, _ = core.utils.resolve_var(time_window, ctx.var)
- if err then
- return nil, "could not resolve vars in time_window: " .. err
- end
- time_window = tonumber(time_window)
- if not time_window then
- return nil, "resolved time_window is not a number: " ..
tostring(time_window)
- end
- end
+ return true
+end
+
- core.log.info("limit count: ", count, ", time_window: ", time_window)
+local function create_limit_obj(conf, rule, plugin_name)
+ core.log.info("create new " .. plugin_name .. " plugin instance",
Review Comment:
```suggestion
core.log.info("create new ", plugin_name, " plugin instance",
```
--
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]