feat: Add Mode() Method to rueidis.Client for Detecting Client Mode#794
Merged
rueian merged 8 commits intoredis:mainfrom Mar 7, 2025
Merged
feat: Add Mode() Method to rueidis.Client for Detecting Client Mode#794rueian merged 8 commits intoredis:mainfrom
Mode() Method to rueidis.Client for Detecting Client Mode#794rueian merged 8 commits intoredis:mainfrom
Conversation
Signed-off-by: Cheyu Wu <cheyu1220@gmail.com>
Signed-off-by: Cheyu Wu <cheyu1220@gmail.com>
FZambia
reviewed
Mar 6, 2025
| // https://github.com/valkey-io/valkey/blob/1a34a4ff7f101bb6b17a0b5e9aa3bf7d6bd29f68/src/networking.c#L4118-L4124 | ||
| ModeCluster ClientMode = "cluster" | ||
| ModeSentinel ClientMode = "sentinel" | ||
| ModeStandalone ClientMode = "standalone" |
Contributor
There was a problem hiding this comment.
Should be with Client prefix:
ClientModeCluster ClientMode = "cluster"
ClientModeSentinel ClientMode = "sentinel"
ClientModeStandalone ClientMode = "standalone"
Contributor
Author
There was a problem hiding this comment.
Oops, I will fix this
Contributor
Author
|
also cc @rueian |
rueian
reviewed
Mar 6, 2025
| } | ||
|
|
||
| func (c *singleClient) Mode() ClientMode { | ||
| return c.mode |
Collaborator
There was a problem hiding this comment.
Suggested change
| return c.mode | |
| return ClientModeStandalone |
| cmd Builder | ||
| retry bool | ||
| DisableCache bool | ||
| mode ClientMode |
Collaborator
There was a problem hiding this comment.
Suggested change
| mode ClientMode |
| retry: !opt.DisableRetry, | ||
| retryHandler: retryer, | ||
| stopCh: make(chan struct{}), | ||
| mode: ClientModeCluster, |
Collaborator
There was a problem hiding this comment.
Suggested change
| mode: ClientModeCluster, |
| } | ||
|
|
||
| func (c *clusterClient) Mode() ClientMode { | ||
| return c.mode |
Collaborator
There was a problem hiding this comment.
Suggested change
| return c.mode | |
| return ClientModeCluster |
| retry: !opt.DisableRetry, | ||
| retryHandler: retryer, | ||
| replica: opt.ReplicaOnly, | ||
| mode: ClientModeSentinel, |
Collaborator
There was a problem hiding this comment.
Suggested change
| mode: ClientModeSentinel, |
| cmd Builder | ||
| retry bool | ||
| replica bool | ||
| mode ClientMode |
Collaborator
There was a problem hiding this comment.
Suggested change
| mode ClientMode |
| } | ||
|
|
||
| func (c *sentinelClient) Mode() ClientMode { | ||
| return c.mode |
Collaborator
There was a problem hiding this comment.
Suggested change
| return c.mode | |
| return ClientModeSentinel |
Signed-off-by: Cheyu Wu <cheyu1220@gmail.com>
1ad61f9 to
6d9ed43
Compare
Contributor
Author
|
Hi @rueian, I have solved those issues, PTAL |
Collaborator
Signed-off-by: Cheyu Wu <cheyu1220@gmail.com>
Contributor
Author
Collaborator
|
Merged. Thanks @CheyuWu! |
Contributor
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why do we need this?
Previously, Centrifugo required explicit Redis Cluster configuration because the Centrifuge library generates keys differently in cluster mode (using hash tags). However, this approach is inconvenient because cloud providers typically provide a Redis URL (e.g.,
redis://...) without explicitly indicating whether it is a standalone Redis or a Redis Cluster. This prevents users from simply reusing the endpoint when starting Centrifugo.New Interface Definition
Closes #790