membphis commented on code in PR #12900:
URL: https://github.com/apache/apisix/pull/12900#discussion_r2689386787
##########
apisix/plugins/limit-count/init.lua:
##########
@@ -205,8 +205,21 @@ local function gen_limit_key(conf, ctx, key)
-- Here we use plugin-level conf version to prevent the counter from being
resetting
-- because of the change elsewhere.
-- A route which reuses a previous route's ID will inherits its counter.
- local conf_type = ctx.conf_type_without_consumer or ctx.conf_type
- local conf_id = ctx.conf_id_without_consumer or ctx.conf_id
+ local parent = conf._meta and conf._meta.parent
+ if not parent or not parent.resource_key or not parent.resource_version
then
+ core.log.error("failed to generate key invalid parent: ",
core.json.encode(parent))
+ return nil
+ end
+
+ local match, err = ngx.re.match(parent.resource_key,
[[/apisix/([^/]+)/([^/]+)]])
+
Review Comment:
remove this useless line
##########
apisix/plugins/limit-count/init.lua:
##########
@@ -205,8 +205,21 @@ local function gen_limit_key(conf, ctx, key)
-- Here we use plugin-level conf version to prevent the counter from being
resetting
-- because of the change elsewhere.
-- A route which reuses a previous route's ID will inherits its counter.
- local conf_type = ctx.conf_type_without_consumer or ctx.conf_type
- local conf_id = ctx.conf_id_without_consumer or ctx.conf_id
+ local parent = conf._meta and conf._meta.parent
+ if not parent or not parent.resource_key or not parent.resource_version
then
+ core.log.error("failed to generate key invalid parent: ",
core.json.encode(parent))
+ return nil
+ end
+
+ local match, err = ngx.re.match(parent.resource_key,
[[/apisix/([^/]+)/([^/]+)]])
+
+ if not match then
+ core.log.error("failed to generate key invalid parent resource key,
err: ", err)
Review Comment:
I think we can remove the `etcd_prefix`, then it should be enough
we can always use it directly, eg: `routes/r1`
```yaml
etcd:
host:
- "http://127.0.0.1:2379" # Replace with your etcd cluster host(s)
prefix: "/apisix" # The default prefix, modify as needed
timeout: 30
--
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]