go-redis icon indicating copy to clipboard operation
go-redis copied to clipboard

What's the difference between SentinelClient and FailoverClient?

Open leaxoy opened this issue 4 years ago • 6 comments

First, I think SentinelClient is used redis sentinel strategy, but then I find there is FailoverClient which use sentinel strategy in it's comments. Now, I'm so confused, can someone explain difference between the two clients.

leaxoy avatar Apr 27 '20 03:04 leaxoy

There is a discussion here :) https://github.com/go-redis/redis/issues/1179

tomnlittle avatar Jun 03 '20 07:06 tomnlittle

@tomnlittle , I have a follow-up question. FailoverClient accepts a list of sentinel addresses in FailoverOptions. But SentinelClient 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? Or do I miss something?

dmitsh avatar Aug 21 '20 15:08 dmitsh

I also faced this problem...

jwrookie avatar Aug 24 '20 07:08 jwrookie

I created issue #1451

dmitsh avatar Aug 24 '20 22:08 dmitsh

I'm not sure I am referring to newer version but as per method NewFailoverClient documentation it already offers automatic failover:

NewFailoverClient returns a Redis client that uses Redis Sentinel for automatic failover. It's safe for concurrent use by multiple goroutines.

However if you want to iterate and create failover mechanics by your own you can use NewSentinelClient in your business logic as it is done in NewFailoverClient implementation, for example: https://github.com/go-redis/redis/blob/v8.3.3/sentinel.go#L512

I think you was mistaken since NewFailoverClient describes a strategy while NewSentinelClientdescribes just a type/struct used by a strategy.

deividaspetraitis avatar Nov 04 '20 16:11 deividaspetraitis

thanks

------------------ 原始邮件 ------------------ 发件人: "notifications"<[email protected]>; 发送时间: 2020年11月5日(星期四) 凌晨0:56 收件人: "go-redis/redis"<[email protected]>; 抄送: "为为"<[email protected]>; "Comment"<[email protected]>; 主题: Re: [go-redis/redis] What's the difference between SentinelClient and FailoverClient? (#1310)

I'm not sure I am referring to newer version but as per method NewFailoverClient documentation it already offers automatic failover:

NewFailoverClient returns a Redis client that uses Redis Sentinel for automatic failover. It's safe for concurrent use by multiple goroutines.

However if you want to iterate and create failover mechanics by your own you can use NewSentinelClient in your business logic as it is done in NewFailoverClient implementation, for example: https://github.com/go-redis/redis/blob/v8.3.3/sentinel.go#L512

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

jwrookie avatar Nov 13 '20 02:11 jwrookie

This issue is marked stale. It will be closed in 30 days if it is not updated.

github-actions[bot] avatar Sep 22 '23 00:09 github-actions[bot]