AlinsRan commented on code in PR #12751:
URL: https://github.com/apache/apisix/pull/12751#discussion_r2532829411


##########
apisix/plugins/limit-count/init.lua:
##########
@@ -275,11 +277,24 @@ function _M.rate_limit(conf, ctx, name, cost, dry_run)
     key = gen_limit_key(conf, ctx, key)
     core.log.info("limit key: ", key)
 
+    local phase = get_phase()
+    if phase == "log" then
+        if not conf.policy or conf.policy == "local" then
+            lim:incoming(key, not dry_run, conf, cost)

Review Comment:
   This conditional statement is unnecessary, as an identical check is 
performed again a few lines later:
   ```lua
   local delay, remaining, reset
       if not conf.policy or conf.policy == "local" then
           delay, remaining, reset = lim:incoming(key, not dry_run, conf, cost)
       else
           delay, remaining, reset = lim:incoming(key, cost, dry_run)
       end
   ```
   
   And why do we need to perform two incoming operations during the log phase?



-- 
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]

Reply via email to