Skip to content

Commit 6820ea8

Browse files
committed
Only return healthy slaves
1 parent 5db29e0 commit 6820ea8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/resty/redis/sentinel.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ function _M.get_slaves(sentinel, master_name)
3636
for i = 1, num_recs, 2 do
3737
host[slave[i]] = slave[i + 1]
3838
end
39-
host.host = host.ip -- for parity with other functions
40-
tbl_insert(hosts, host)
39+
40+
if host["master-link-status"] == "ok" then
41+
host.host = host.ip -- for parity with other functions
42+
tbl_insert(hosts, host)
43+
end
4144
end
4245
if hosts[1] ~= nil then
4346
return hosts

0 commit comments

Comments
 (0)