Skip to content

Commit f33a732

Browse files
committed
Added all config options as non nil defaults
1 parent de691c7 commit f33a732

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lib/resty/redis/connector.lua

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,19 @@ local DEFAULTS = setmetatable({
8989
connect_timeout = 100,
9090
read_timeout = 1000,
9191
connection_options = nil, -- pool, etc
92-
93-
-- TODO Keepalive settings
92+
keepalive_timeout = 60000,
93+
keepalive_poolsize = 30,
9494

9595
host = "127.0.0.1",
9696
port = 6379,
97-
path = nil, -- /tmp/redis.sock
98-
password = nil,
97+
path = "", -- /tmp/redis.sock
98+
password = "",
9999
db = 0,
100+
100101
master_name = "mymaster",
101-
role = "master", -- master | slave | any (tries master first, failover to a slave)
102-
sentinels = nil,
102+
role = "master", -- master | slave | any
103+
sentinels = {},
104+
103105
cluster_startup_nodes = {},
104106
}, fixed_field_metatable)
105107

@@ -176,7 +178,7 @@ function _M.connect(self, params)
176178
parse_dsn(params)
177179
end
178180

179-
if params.sentinels then
181+
if #params.sentinels > 0 then
180182
return self:connect_via_sentinel(params)
181183
elseif params.startup_cluster_nodes then
182184
-- TODO: Implement cluster
@@ -296,7 +298,7 @@ function _M.connect_to_host(self, host)
296298
r:set_timeout(self, self.read_timeout)
297299

298300
local password = host.password
299-
if password then
301+
if password and password ~= "" then
300302
local res, err = r:auth(password)
301303
if err then
302304
ngx_log(ngx_ERR, err)

0 commit comments

Comments
 (0)