socketio / socket.io-redis-streams-adapter

The Socket.IO adapter based on Redis Streams, allowing to broadcast events between several Socket.IO servers.
https://socket.io/docs/v4/redis-streams-adapter/
MIT License
30 stars 15 forks source link

Request support for Redis Cluster #3

Closed seolhw closed 8 months ago

MGTechTeam1 commented 1 year ago

Bump +1

titk12 commented 1 year ago

Bump +1

giuliopulina commented 9 months ago

Doesn't this library support connecting to a Redis Cluster? In either case, cluster connection should be mentioned in the documentation, IMHO

darrachequesne commented 8 months ago

It does indeed support connecting to a Redis cluster.

I have added a test to ensure it: https://github.com/socketio/socket.io-redis-streams-adapter/commit/65d0539eb7eb9649845ee744a4de4e0646fa194e

@seolhw @MGTechTeam1 @titk12 could you please check?

darrachequesne commented 8 months ago

I've added an example in the README:

import { createCluster } from "redis";
import { Server } from "socket.io";
import { createAdapter } from "@socket.io/redis-streams-adapter";

const redisClient = createCluster({
  rootNodes: [
    {
      url: "redis://localhost:7000",
    },
    {
      url: "redis://localhost:7001",
    },
    {
      url: "redis://localhost:7002",
    },
  ],
});

await redisClient.connect();

const io = new Server({
  adapter: createAdapter(redisClient)
});

io.listen(3000);

I think this can be closed now, please reopen if needed.