DriverX / aioredis-cluster

Redis Cluster support extension for aioredis
MIT License
24 stars 7 forks source link

PubSub support for multiple channels and context managers #23

Open BenjaminYong opened 1 year ago

BenjaminYong commented 1 year ago

Hi @DriverX , I was testing the sharded ssubscribe and subscribe function and noticed that PubSubs in your library are limited to a single channel, getting error:

Are there plans to support multiple channels? Clients should be able to subscribe to multiple channels so long as they belong to the same slot. https://redis.io/commands/ssubscribe/.

Also, is it possible to open a Pub/Sub context manager to handle subscription messages? In aioredis, this is possible like this example: https://aioredis.readthedocs.io/en/latest/examples/#pubsub.

i.e.

channels = ['{key}:123', '{key}:456']
async with self.redis_cluster.pubsub() as pubsub:
    await pubsub.ssubscribe(*channels)

    async for result in pubsub.listen():
        yield result

Many thanks!