Skip to content

Commit e4f6cc0

Browse files
committed
Default connection options to empty table
1 parent 91d7d47 commit e4f6cc0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/resty/redis/connector.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ end
8888
local DEFAULTS = setmetatable({
8989
connect_timeout = 100,
9090
read_timeout = 1000,
91-
connection_options = nil, -- pool, etc
91+
connection_options = {}, -- pool, etc
9292
keepalive_timeout = 60000,
9393
keepalive_poolsize = 30,
9494

@@ -174,7 +174,7 @@ end
174174

175175

176176
function _M.connect(self, params)
177-
local params = tbl_copy_merge_defaults(params, DEFAULTS)
177+
local params = tbl_copy_merge_defaults(params, self.config)
178178

179179
if params.url then
180180
parse_dsn(params)
@@ -279,14 +279,15 @@ function _M.connect_to_host(self, host)
279279

280280
local ok, err
281281
local socket = host.socket
282+
local opts = self.connection_options
282283
if socket then
283-
if self.connection_options then
284+
if opts then
284285
ok, err = r:connect(socket, self.connection_options)
285286
else
286287
ok, err = r:connect(socket)
287288
end
288289
else
289-
if self.connection_options then
290+
if opts then
290291
ok, err = r:connect(host.host, host.port, self.connection_options)
291292
else
292293
ok, err = r:connect(host.host, host.port)

0 commit comments

Comments
 (0)