Skip to content

Commit ba29045

Browse files
committed
fix(config) use self.config
1 parent f2fb72e commit ba29045

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lib/resty/redis/connector.lua

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,17 @@ end
129129

130130

131131
function _M.set_connect_timeout(self, timeout)
132-
self.connect_timeout = timeout
132+
self.config.connect_timeout = timeout
133133
end
134134

135135

136136
function _M.set_read_timeout(self, timeout)
137-
self.read_timeout = timeout
137+
self.config.read_timeout = timeout
138138
end
139139

140140

141141
function _M.set_connection_options(self, options)
142-
self.connection_options = options
142+
self.config.connection_options = options
143143
end
144144

145145

@@ -277,20 +277,21 @@ end
277277

278278
function _M.connect_to_host(self, host)
279279
local r = redis.new()
280-
r:set_timeout(self.connect_timeout)
280+
local config = self.config
281+
r:set_timeout(config.connect_timeout)
281282

282283
local ok, err
283284
local socket = host.socket
284-
local opts = self.connection_options
285+
local opts = config.connection_options
285286
if socket then
286287
if opts then
287-
ok, err = r:connect(socket, self.connection_options)
288+
ok, err = r:connect(socket, config.connection_options)
288289
else
289290
ok, err = r:connect(socket)
290291
end
291292
else
292293
if opts then
293-
ok, err = r:connect(host.host, host.port, self.connection_options)
294+
ok, err = r:connect(host.host, host.port, config.connection_options)
294295
else
295296
ok, err = r:connect(host.host, host.port)
296297
end
@@ -300,7 +301,7 @@ function _M.connect_to_host(self, host)
300301
ngx_log(ngx_ERR, err, " for ", host.host, ":", host.port)
301302
return nil, err
302303
else
303-
r:set_timeout(self, self.read_timeout)
304+
r:set_timeout(self, config.read_timeout)
304305

305306
local password = host.password
306307
if password and password ~= "" then

t/config.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ location /t {
103103
})
104104

105105
assert(rc == nil, "rc should be nil")
106-
assert(err == "field foo does not exist", "err should contain error")
106+
assert(string.find(err, "field foo does not exist"),
107+
"err should contain error")
107108

108109
-- Provide all options, without errors
109110

0 commit comments

Comments
 (0)