Skip to content

Commit

Permalink
fix(plugin/rate-limiting) correctly handle config.redis_database
Browse files Browse the repository at this point in the history
Use the default connection pool if `config.redis_database` is `0`.
  • Loading branch information
ADD-SP authored and dndx committed Apr 11, 2022
1 parent 8716741 commit 32709aa
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions kong/plugins/rate-limiting/policies/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ local function get_redis_connection(conf)

-- use a special pool name only if redis_database is set to non-zero
-- otherwise use the default pool name host:port
sock_opts.pool = conf.redis_database and
conf.redis_host .. ":" .. conf.redis_port ..
":" .. conf.redis_database
if conf.redis_database ~= 0 then
sock_opts.pool = fmt( "%s:%d;%d",
conf.redis_host,
conf.redis_port,
conf.redis_database)
end

local ok, err = red:connect(conf.redis_host, conf.redis_port,
sock_opts)
if not ok then
Expand Down

0 comments on commit 32709aa

Please sign in to comment.