Reputation: 31
I'm adding Redis support to an open-source project written in Go. The goal is to support all Redis topologies: server, cluster, sentinel.
I browsed Go clients listed in redis.io/clients, and it seems that github.com/go-redis/redis project is a viable option.
My main concern is the NewSentinelClient() method accepts a single sentinel address. According to the Guidelines for Redis clients (redis.io/topics/sentinel-clients#guidelines-for-redis-clients-with-support-for-redis-sentinel), "the client should iterate the list of Sentinel addresses. "
How can SentinelClient iterate through the rest of sentinel instances, if it only has one sentinel address?
Do I miss something?
On the same topic, could someone recommend another Go Redis client that might be suitable for this scenario?
Upvotes: 3
Views: 4953
Reputation: 1306
Use NewFailoverClient if you have multiple sentinels.
rdb := redis.NewFailoverClient(&redis.FailoverOptions{
MasterName: "mymaster",
SentinelAddrs: []string{
"sentinel_1:26379",
"sentinel_2:26379",
"sentinel_3:26379",
},
})
Upvotes: 1