The central hub for Microstream, a lightweight, real-time communication system for microservices. Routes messages between services, handles service discovery, and ensures seamless communication with WebSockets. Perfect for building scalable, event-driven architectures.
Author: Arijit Banerjee
License: MIT
- Features β¨
- How Does It Work? π
- Deployment π
- Client SDK π
- Author π¨βπ»
- Contributing π€
- License π
- π’ Central WebSocket server for real-time communication between microservices.
- π Service discovery and registration.
- π‘ Request routing and response handling.
- β€οΈ Heartbeat mechanism to detect and remove inactive services.
- π Configurable logging for better observability.
- π Real-time inter-service communication using WebSockets.
- β‘ Synchronous request-response pattern without HTTP overhead.
- π Auto-discovery and connection management.
MicroStream simplifies communication between microservices using a centralized hub-and-spoke architecture, also known as a star network. In this model, the MicroStream Hub acts as the central communication point, and your microservices, equipped with the MicroStream Client, connect to the Hub and communicate through it.
Here's how it works:
Imagine a star:
- The center of the star is the MicroStream Hub.
- The points of the star are your microservices (each equipped with the MicroStream Client).
In this setup:
- The Hub acts as the central communication point.
- Services (nodes) connect to the Hub and communicate through it, not directly with each other.
-
Service Registration:
- Each microservice connects to the Hub using the MicroStream Client.
- The Hub automatically detects and registers the service.
-
Request-Response Communication in Real-Time:
-
Auto-Discovery:
- Once connected, the Hub keeps track of all connected services, so you donβt need to manually configure connections between services. However, you still need to specify the target service and method when sending a request.
-
Heartbeat Mechanism:
MicroStream is designed to make microservice communication simple, efficient, and scalable. Hereβs why youβll love it:
- Easy Setup: Minimal configuration required to get started.
- Real-Time Request-Response Communication: Built on WebSockets for instant, reliable data exchange.
- Auto-Service-Management: Once connected, the Hub keeps track of all services, simplifying network management.
- Scalable: Easily add more services without reconfiguring the network.
- Lightweight: Minimal overhead compared to traditional REST or gRPC.
- Flexible: Works seamlessly with any microservice architecture.
docker compose up --build
To change the port in Docker Compose, you can set the PORT
environment variable in the docker-compose.yml
file:
version: "3.8"
services:
microstream-hub:
build: .
ports:
- "${PORT:-3000}:3000"
environment:
- PORT=3000
restart: unless-stopped
npm install
node src/hub.js
To change the port, you can set the PORT
environment variable:
PORT=4000 node src/hub.js
We provide a client SDK for easy integration with the MicroStream Hub.
Author: Arijit Banerjee
About: Full Stack Web Developer | Cyber Security Enthusiast | Actor
Social Media: Β
Instagram
Β
LinkedIn
Β
GitHub
Β
Website
Email: [email protected]
We welcome contributions! Please see our CONTRIBUTING.md for guidelines on how to contribute to this project.
This project is licensed under the MIT License. See the LICENSE file for details.