Open AlexProfi opened 5 years ago
the same issue, I dont know how to use that method. @AlexProfi have you get the solution?
You're generally better off using the role
param when calling connect_via_sentinel
.
The get_master
and get_slaves
methods are used internally by connect_via_sentinel
.
https://github.com/ledgetech/lua-resty-redis-connector/blob/master/lib/resty/redis/connector.lua#L237
If you do want to use them directly the first argument is an instance of resty-redis
already connected to a sentinel and the second arg is the master name configuration in sentinel.
e.g. something like this (untested code)
local sentinel = require("resty.redis").new()
sentinel:connect("my_sentinel.host", 6380)
local master = require("resty.redis.sentinel").get_master(sentinel, "my_master_name")
@AlexProfi can I use the method in stream that load balance the redis, when the redis master down and pick a new one immediately.
@hamishforbes
I don't really understand.
If you use the sentinel syntax (https://github.com/ledgetech/lua-resty-redis-connector#connections-via-redis-sentinel) then it will always ask sentinel for the current master and then make a connection to that host.
Please describe how to use method sentinel.get_master method after I get connected redis after connect_via_sentinel