I have a code which connects to sentinels and discovers redis master address. After discovering master we create redis master object and perform redis operations afterwards. The problem here is that after sentinel failover process the redis master address gets changed and new master is promoted by the sentinels, in that case the redis master object should be updated at the run time. Can anyone tell how this can be achieved in real time?
from redis import Redis
from redis.sentinel import Sentinel
sentinel = Sentinel([('192.168.10.1', 26379), ('192.168.10.2', 26379),
('192.168.10.3', 26379)], socket_timeout=0.1)
redis_master = sentinel.discover_master("master-name")
host, port = redis_master
master_object = Redis(host, port)
master_object.get("data")