-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
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.
IConnectionMultiplexer sentinel = ConnectionMultiplexer.Connect(new ConfigurationOptions {
ServiceName = _redisSentinelServiceName,
EndPoints = { { _redisSentinelHost, 26379 } },
CommandMap = CommandMap.Sentinel
});
IConnectionMultiplexer master = sentinel.GetSentinelMasterConnection(new ConfigurationOptions {
ServiceName = _redisSentinelServiceName
});Looks like it should work... but there are 2 problems with this code.
IConnectionMultiplexerdoes not have aGetSentinelMasterConnectionfunction.- The sentinel
ConfigurationOptionsMUST haveTieBreaker = ""to work.
I have a few suggestions:
- Add
GetSentinelMasterConnectiontoIConnectionMultiplexer - Have a separate
ConnectionMultiplexer.ConnectSentinel(...)function, which setsCommandMapandTieBreakerto the required values, and make endpoints default to port 26379. - Just use the
ServiceNameprovided 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.
ejsmith
Metadata
Metadata
Assignees
Labels
No labels