I’m trying to create a new websocket app server with sanic. It should be 2+ server running sanic and get message pubsub via redis.
Can someone guide me how to compose sanic, asyncio things, websockets and aioredis ?
Somethings that come to my mind now:
- For each ws request, create a consumer handler & a producer handler for that ws, and then asyncio.await them
- In the consumer handler, we subscribe to the redis channel using aioredis
- In the producer handler, we publish the message to redis channel to broadcast and send a message to the ws instance, too ?