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


##########
apisix/plugins/limit-count/limit-count-redis-cluster.lua:
##########
@@ -57,26 +47,33 @@ function _M.new(plugin_name, limit, window, conf)
 end
 
 
-function _M.incoming(self, key, cost)
-    local red = self.red_cli
-    local limit = self.limit
-    local window = self.window
-    key = self.plugin_name .. tostring(key)
+function _M.incoming(self, key, cost, dry_run)
+    local commit = true
+    if dry_run ~= nil then
+        commit = not dry_run
+    end
 
-    local ttl = 0
-    local res, err = red:eval(script, 1, key, limit, window, cost or 1)
+    return util.redis_incoming(self, self.red_cli, key, commit, cost)
+end
 
-    if err then
-        return nil, err, ttl
-    end
 
-    local remaining = res[1]
-    ttl = res[2]
+local function log_phase_incoming_thread(premature, self, key, cost)

Review Comment:
   I disagree. Similar logic also appears in the limit-conn.
   
https://github.com/apache/apisix/blob/7e907a565b9302e70daf294398722377fd64c482/apisix/plugins/limit-conn/limit-conn-redis.lua#L60-L81
   
    If I put this logic into ai-rate-limiting plugin, it will make the plugin 
too complicated. I have to copy a lot of logic from limit-count. Currently, the 
ai-rate-limiting is just a simple wrapper of limit-count.
   
   Or, do you think I need to rewrite the ai-rate-limiting to something like 
limit-ai-redis.lua and limit-ai-redis-cluster.lua?



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