tdjs.tech

dwsps

Tiny distributed websocket pub/sub system


dwsps, distributed websocket pub/sub, is exactly what it says on the tin - a node module that provides the capability to set up a distributed publish/subscribe system over websockets.

It's a topic based system and uses the . delimiter to separate increasingly specific topics. For example, a user/machine could subscribe to the topic log.error. They would receive messages published to log.error and log.error.critical, but not log.warning.

Because dwsps is so small and simple (~1kb), it is incredibly fast. Messages are JSON formatted and contain little metadata so they are transmitted and received instantly over websockets. Client actions (subscribe, unsubscribe etc.) are acknowledged by the server so that the client knows the request was received.

A small system may only consist of a single server and a few clients. However, in larger more complex systems, servers can be peered so that messages can be delivered between them. For example, a server A with a client X can be peered with a server B with a client Y. Then, a message published by client X to server A will be forwarded to server B and delivered to client Y, assuming that they are subscribed to a relevant channel.

For usage examples head over to the GitHub repository.


https://github.com/tdjsnelling/dwsps