ueberdosis / hocuspocus

The CRDT Yjs WebSocket backend for conflict-free real-time collaboration in your app.
https://tiptap.dev/docs/hocuspocus/introduction
MIT License
1.2k stars 115 forks source link

Support multiple server instances communicating with each other in HA setup #720

Open rahul1995 opened 11 months ago

rahul1995 commented 11 months ago

The problem I am facing For some reason, I would want to close all the connections for a particular document. My other microservice will call Collaboration server to close all the connections. In HA setup, there will be multiple server instances. But the call will come to only one server instance. It can close the connections made on this server, but this message needs to be broadcasted to all the server instances.

The solution I would like Currently "extension-redis" supports message passing from client -> server and server -> all client instances. But there is no way for server to "tell" other server to perform something at the server. The handleIncomingMessage is also non-extendable so that a custom strategy could be hooked in. Also, MessageReceiver's apply method is also non-extendable and can only support the MessageTypes coming OOTB. So, I cannot find any easy way to extend the functionality.

Alternatives I have considered Currently, thinking of writing a custom extension similar to extension-redis with some change in behaviour of handleIncomingMessage(). Not tried yet.

Additional context Add any other context or screenshots here.

rahul1995 commented 11 months ago

Alternative I am using right now - I extended Redis-extension class and created two more pub, sub redis clients to publish/listen server-to-server messages.

ZhangMingZhao1 commented 2 months ago

Alternative I am using right now - I extended Redis-extension class and created two more pub, sub redis clients to publish/listen server-to-server messages.

Can you share the code?