3

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?

dmitsh
  • 31
  • 1
  • 4
  • AFAIK, you should connect to the master node. go-redis is a good choice, the problem you are facing is with your redis-sentinel not with your client. – Davood Falahati Aug 21 '20 at 21:08

1 Answers1

1

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",
    },
})
z11i
  • 951
  • 11
  • 26