uds-pubsub
v1.0.1
Published
Lightweight Unix Domain Socket pub/sub library for Node.js
Maintainers
Readme
📡 uds-pubsub
Lightweight, local publish/subscribe messaging for Node.js using Unix Domain Sockets.
✅ Simple API
✅ Fast IPC for local processes
✅ Topics, subscriptions, and routing
✅ Ideal for microservice-like Node.js apps on a single machine
✅ Zero external dependencies (no Redis, no MQTT broker)
🚀 Installation
npm install uds-pubsub✨ Key Features
Familiar EventEmitter-like API
Supports topics (like MQTT channels)
Efficient Unix Domain Socket IPC
Simple
subscribe,unsubscribe,publishworkflowCan be embedded in any Node.js app or CLI tool
Lightweight, fast, no external brokers
🔧 API Overview
Create a Host (Broker)
import { UdsPubSubHost } from 'uds-pubsub';
const host = new UdsPubSubHost();
await host.start();Create a Client
import { createClient } from 'uds-pubsub';
const client = createClient({ name: 'weather-sensor' });
await client.connect();Subscribe to a Topic
client.subscribe('weather/temperature', (payload) => {
console.log('Temperature update:', payload);
});Publish to a Topic
client.publish('weather/temperature', { temp: 23.4 });Unsubscribe from a Topic
client.unsubscribe('weather/temperature');Close the Connection
client.close();🏗️ Architecture Diagram
+--------------------+ +-------------------+
| weather-sensor | | weather-display |
| (publishes) | | (subscribes) |
+--------+-----------+ +---------+---------+
| ^
| |
v |
+---+----------------------------------+
| uds-pubsub Host (Broker) |
| - Handles topics & routing |
| - Uses Unix Domain Sockets (UDS) |
+--------------------------------------+
🛠️ Advanced Options
Customize Socket Path
createClient({
name: 'custom-client',
socketPath: '/tmp/my-custom.sock'
});const host = new UdsPubSubHost('/tmp/my-custom.sock');📄 License
MIT License
🤝 Contributing
PRs and issues welcome!
Please open an issue before submitting large changes.
