Skip to content

Commit 79d5bf8

Browse files
committed
removed 'any' mode, which hasn't worked in a while
1 parent 140e6fe commit 79d5bf8

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

lib/resty/redis/connector.lua

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ local DEFAULTS = setmetatable({
100100
url = "", -- DSN url
101101

102102
master_name = "mymaster",
103-
role = "master", -- master | slave | any
103+
role = "master", -- master | slave
104104
sentinels = {},
105105

106106
-- Redis proxies typically don't support full Redis capabilities
@@ -151,7 +151,7 @@ local function parse_dsn(params)
151151
-- password may not be present
152152
if #m < 5 then tbl_remove(fields, 1) end
153153

154-
local roles = { m = "master", s = "slave", a = "any" }
154+
local roles = { m = "master", s = "slave" }
155155

156156
local parsed_params = {}
157157

@@ -232,7 +232,7 @@ function _M.connect_via_sentinel(self, params)
232232
return nil, err, previous_errors
233233
end
234234

235-
if role == "master" or role == "any" then
235+
if role == "master" then
236236
local master, err = get_master(sentnl, master_name)
237237
if master then
238238
master.db = db
@@ -248,31 +248,32 @@ function _M.connect_via_sentinel(self, params)
248248
end
249249
end
250250
end
251-
end
252251

253-
-- We either wanted a slave, or are failing over to a slave "any"
254-
local slaves, err = get_slaves(sentnl, master_name)
255-
sentnl:set_keepalive()
252+
else
253+
-- We want a slave
254+
local slaves, err = get_slaves(sentnl, master_name)
255+
sentnl:set_keepalive()
256256

257-
if not slaves then
258-
return nil, err
259-
end
257+
if not slaves then
258+
return nil, err
259+
end
260260

261-
-- Put any slaves on 127.0.0.1 at the front
262-
tbl_sort(slaves, sort_by_localhost)
261+
-- Put any slaves on 127.0.0.1 at the front
262+
tbl_sort(slaves, sort_by_localhost)
263263

264-
if db or password then
265-
for i,slave in ipairs(slaves) do
266-
slave.db = db
267-
slave.password = password
264+
if db or password then
265+
for i,slave in ipairs(slaves) do
266+
slave.db = db
267+
slave.password = password
268+
end
268269
end
269-
end
270270

271-
local slave, err, previous_errors = self:try_hosts(slaves)
272-
if not slave then
273-
return nil, err, previous_errors
274-
else
275-
return slave
271+
local slave, err, previous_errors = self:try_hosts(slaves)
272+
if not slave then
273+
return nil, err, previous_errors
274+
else
275+
return slave
276+
end
276277
end
277278
end
278279

0 commit comments

Comments
 (0)