Skip to content

Make shards in redis.Ring publicly accessible #3341

Closed
@jaapz

Description

@jaapz

We use redis.Ring to shard load across servers. We shard mainly PubSub related commands, PSUBSCRIBE, SUBSCRIBE, PUNSUBSCRIBE and UNSUBSCRIBE.

Because these commands put the redis connection in a special "pubsub" mode, after which you cannot use it for anything else than pubsub, we try to re-use these connections as much as possible.

What we'd like to do is set up a pubsub connection for every shard in the ring at application start, and then re-use that pubsub connection when we need to subscribe or unsubscribe on a topic.

However for that to be possible, we need two things:

  • access to the list of shards, so we can immediately create a pubsub connection for each shard in the ring
  • access to ringSharding.GetByKey so we can determine which shard pubsub connection we can re-use for a given topic

However, on redis.Ring the sharding attribute, which contains an instance of *ringSharding, is not publicly accessible, so we cannot access the shards list or the GetByKey function.

We are working around this for now, but it's rather ugly, because we need to make assumptions in our own code on how topics are distributed over the ring.

Would it be possible to make redis.Ring.sharding public, or at least provide some public methods on redis.Ring to return the list of shards access the GetByKey function?

I would be open to create a merge request if there is a chance of it being accepted.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions