You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**MicroStream** simplifies communication between microservices using a **centralized hub-and-spoke architecture**, also known as a **star network**. In this model, the **[MicroStream Hub](https://github.com/arijitcodes/microstream-hub)** acts as the central communication point, and your microservices, equipped with the **[MicroStream Client](https://github.com/arijitcodes/microstream-client)**, connect to the Hub and communicate through it.
74
+
75
+
Here's how it works:
76
+
77
+
### 🌟 The Star Network Concept
78
+
79
+
Imagine a star:
80
+
81
+
- The **center of the star** is the **[MicroStream Hub](https://github.com/arijitcodes/microstream-hub)**.
82
+
- The **points of the star** are your **microservices** (each equipped with the **[MicroStream Client](https://github.com/arijitcodes/microstream-client)**).
83
+
84
+

85
+
86
+
In this setup:
87
+
88
+
- The **Hub** acts as the central communication point.
89
+
-**Services** (nodes) connect to the Hub and communicate through it, **not directly with each other**.
90
+
91
+
### 🚀 How It Works in Practice
92
+
93
+
1.**Service Registration**:
94
+
95
+
- Each microservice connects to the Hub using the **[MicroStream Client](https://github.com/arijitcodes/microstream-client)**.
96
+
- The **[Hub](https://github.com/arijitcodes/microstream-hub)** automatically detects and registers the service.
97
+
98
+
2.**Request-Response Communication in Real-Time**:
99
+
100
+
- When **Service A** needs to talk to **Service B**, it sends a request to the **[Hub](https://github.com/arijitcodes/microstream-hub)**.
101
+
- The **[Hub](https://github.com/arijitcodes/microstream-hub)** routes the request to **Service B**.
102
+
-**Service B** processes the request and sends a response back through the **[Hub](https://github.com/arijitcodes/microstream-hub)**.
103
+
- All communication happens in **real-time** over WebSockets, ensuring fast and reliable data exchange.
104
+
105
+
3.**Auto-Discovery**:
106
+
107
+
- Once connected, the **[Hub](https://github.com/arijitcodes/microstream-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.
108
+
109
+
4.**Heartbeat Mechanism**:
110
+
- Services send regular "heartbeats" to the **[Hub](https://github.com/arijitcodes/microstream-hub)** to confirm they’re active.
111
+
- If a service stops sending heartbeats, the **[Hub](https://github.com/arijitcodes/microstream-hub)** removes it from the network.
112
+
113
+
### ✨ Why Choose MicroStream?
114
+
115
+
**MicroStream** is designed to make microservice communication **simple**, **efficient**, and **scalable**. Here’s why you’ll love it:
116
+
117
+
-**Easy Setup**: Minimal configuration required to get started.
118
+
-**Real-Time Request-Response Communication**: Built on WebSockets for instant, reliable data exchange.
119
+
-**Auto-Service-Management**: Once connected, the **[Hub](https://github.com/arijitcodes/microstream-hub)** keeps track of all services, simplifying network management.
120
+
-**Scalable**: Easily add more services without reconfiguring the network.
121
+
-**Lightweight**: Minimal overhead compared to traditional REST or gRPC.
122
+
-**Flexible**: Works seamlessly with any microservice architecture.
1.**Configuration**: The [`MicrostreamClient`](#microstreamclientoptions) is configured with the URL of the Microstream Hub, the name of your service, and the log level.
161
+
1.**Configuration**: The [`MicrostreamClient`](#microstreamclientoptions) is configured with the URL of the [Microstream Hub](#microstream-hub-), the name of your service, and the log level.
106
162
2.**Registering Handlers**: The `onRequest` method is used to register a handler for incoming requests. In this example, the handler responds to an "authenticate" event.
0 commit comments