Baoyuantop commented on code in PR #12861:
URL: https://github.com/apache/apisix/pull/12861#discussion_r2666821849


##########
docs/zh/latest/plugins/limit-conn.md:
##########


Review Comment:
   Please update the English document simultaneously.



##########
apisix/utils/rediscluster.lua:
##########
@@ -24,7 +24,11 @@ local function new_redis_cluster(conf, dict_name)
     local config = {
         name = conf.redis_cluster_name,
         serv_list = {},
+        keepalive_timeout = conf.keepalive_timeout,            --redis 
connection pool idle timeout
+        keepalive_cons = conf.keepalive_pool,                  --redis 
connection pool size

Review Comment:
   ```suggestion
           keepalive_cons = conf.keepalive_pool,                  -- redis 
connection pool size
   ```



##########
apisix/plugins/limit-conn/limit-conn-redis.lua:
##########
@@ -48,7 +48,12 @@ function _M.incoming(self, key, commit)
     if not red then
         return red, err
     end
-    return util.incoming(self, red, key, commit)
+    local delay, incoming_err = util.incoming(self, red, key, commit)
+    local ok, err = red:set_keepalive(conf.keepalive_timeout, 
conf.keepalive_pool)
+    if not ok then
+        core.log.error("set keepalive failed:", err)

Review Comment:
   ```suggestion
           core.log.error("set keepalive failed: ", err)
   ```



##########
apisix/utils/rediscluster.lua:
##########
@@ -24,7 +24,11 @@ local function new_redis_cluster(conf, dict_name)
     local config = {
         name = conf.redis_cluster_name,
         serv_list = {},
+        keepalive_timeout = conf.keepalive_timeout,            --redis 
connection pool idle timeout

Review Comment:
   ```suggestion
           keepalive_timeout = conf.keepalive_timeout,            -- redis 
connection pool idle timeout
   ```



##########
t/plugin/limit-conn-redis.t:
##########
@@ -808,3 +808,50 @@ GET /test_concurrency
 --- response_body
 status:200, count:5
 status:503, count:5
+
+
+
+=== TEST 26: verify redis keepalive
+--- extra_init_by_lua
+    local limit_conn = require("apisix.plugins.limit-conn.limit-conn-redis")
+    local core = require("apisix.core")
+
+    limit_conn.origin_incoming = limit_conn.incoming
+    limit_conn.incoming = function(self, key, commit)
+        local redis = require("resty.redis")
+        local conf = self.conf
+        local delay, err = self:origin_incoming(key, commit)
+        if not delay then
+            ngx.say("limit fail: ", err)
+            return delay, err
+        end
+
+        -- verify connection reused time
+        local red,err = redis:new()
+        if err then
+            core.log.error("failed to create redis cli: ", err)
+            ngx.say("failed to create redis cli: ", err)
+            return nil,err

Review Comment:
   ```suggestion
               return nil, err
   ```



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