Open prk3 opened 3 years ago
Alternative solution: adding a version of PairedConnection that does not reconnect automatically. I could wrap it with a struct overriding send method to react to errors and reconnect with Sentinel logic.
Hello, thanks for raising this.
In principle we should probably do both. The building blocks should be flexible, but Sentinel is something that should be supported directly too. It depends how much more complex the code becomes to make the reconnection logic flexible enough to support it (I'm also aware that code is a bit gnarly in the first place, which doesn't help).
I've been playing with the library and came up with a design that does not change API in a drastic way, yet allows us to:
Check it out and say what you think.
Hi! We're using Sentinel to achieve high availability of Redis databases. It looks like the most popular Redis clients for Rust don't support it. I started digging into this topic and made
redis-async
connect to Sentinel + reconnect when Redis instance goes down.Sentinel connection is basically a paired connection with additional connect/reconnect logic: to find the address of Redis instance we must iterate through sentinel hosts and send
SENTINEL get-master-addr-by-name master-name
command with the normal Redis protocol. The address is then used like in the normal paired connection. When the connection is dropped, we discover the Redis address again repeating the same steps.Unfortunately, it's not possible to change reconnect logic outside of the crate, because we need to access some crate-private items. Sentinel support would have to land in the library, likely as a new connection type, since not all people need it.
@benashford Are you interested in adding Sentinel support to
redis-async
? If so, I could share a POC. How do you see Sentinel in the API?