-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat(ring): add GetShardClients and GetShardClientForKey methods to Ring for shard access #3388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add GetShards() method to retrieve a list of active shard clients. - Add GetShardByKey(key string) method to get the shard client for a specific key. - These methods enable users to manage Pub/Sub operations more effectively by accessing shard-specific clients.
Hello @DengY11 , thank you for this contribution. Please write tests for the code you are introducing. On a side note, would you like to share your usecase of Redis Ring and why you decided to use Ring instead of a Redis OSS Cluster? |
hi @ndyakov |
@DengY11 now I can see the tests, for some reason the diff was not complete. Anyway, would you mind renaming the new functions to |
@ndyakov Thanks for the quick response and the suggestions! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks good, we have flaky tests right now. I will investigate tomorrow. Merging this to include in v9.9.0
This PR adds two new methods to the
Ring
client that provide access to individual shard clients, addressing the need to create dedicated connections (e.g., PubSub) for each shard.When using Redis Ring with PubSub connections, users need to create separate PubSub connections for each shard because PubSub connections enter a special mode and cannot be used for other Redis operations. Currently, there's no way to access the underlying shard clients directly, making it impossible to pre-create and reuse PubSub connections related issue
This PR introduces two new public methods to the
Ring
struct, users can pre-create and reuse PubSub connections per shardGetShards() []*Client
GetShardByKey(key string) (*Client, error)
Checklist:
closes #3341