I implemented support for Redis Sentinel in an application yesterday and I had a rough time getting it to work. I had to actually dig into the library code to figure out what I was doing wrong. If you make a few minor tweaks to the API you could entirely avoid the problems I ran into.
Allow me to explain. This is not the exact code I had; I modified it to illustrate the point.
Looks like it should work... but there are 2 problems with this code.
IConnectionMultiplexer does not have a GetSentinelMasterConnection function.
The sentinel ConfigurationOptionsMUST have TieBreaker = "" to work.
I have a few suggestions:
Add GetSentinelMasterConnection to IConnectionMultiplexer
Have a separate ConnectionMultiplexer.ConnectSentinel(...) function, which sets CommandMap and TieBreaker to the required values, and make endpoints default to port 26379.
Just use the ServiceName provided in the Sentinel configuration, so I don't have to provide it twice
I realize there may be any number of reasons why these suggestions might not make sense (this isn't my code), but please consider if there's some improvements to be made with regard to the library's Sentinel functionality.
I implemented support for Redis Sentinel in an application yesterday and I had a rough time getting it to work. I had to actually dig into the library code to figure out what I was doing wrong. If you make a few minor tweaks to the API you could entirely avoid the problems I ran into. Allow me to explain. This is not the exact code I had; I modified it to illustrate the point.
Looks like it should work... but there are 2 problems with this code.
IConnectionMultiplexer
does not have aGetSentinelMasterConnection
function.ConfigurationOptions
MUST haveTieBreaker = ""
to work.I have a few suggestions:
GetSentinelMasterConnection
toIConnectionMultiplexer
ConnectionMultiplexer.ConnectSentinel(...)
function, which setsCommandMap
andTieBreaker
to the required values, and make endpoints default to port 26379.ServiceName
provided in the Sentinel configuration, so I don't have to provide it twiceI realize there may be any number of reasons why these suggestions might not make sense (this isn't my code), but please consider if there's some improvements to be made with regard to the library's Sentinel functionality.