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
// Create a new MicrostreamClient instance with the necessary configuration
140
140
constclient=newMicrostreamClient({
141
141
hubUrl:"http://localhost:3000", // URL of the Microstream Hub
142
-
serviceName:"auth-service", // Name of your service
142
+
serviceName:"auth-service", // Name of your service - it has to be unique
143
143
logLevel:"debug", // Enable debug logs
144
144
});
145
145
@@ -180,7 +180,7 @@ try {
180
180
181
181
### Explanation 👨🏻🏫
182
182
183
-
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.
183
+
1.**Configuration**: The [`MicrostreamClient`](#microstreamclientoptions) is configured with the URL of the [Microstream Hub](#microstream-hub-), the unique registration name of your service, and the log level.
184
184
2.**Registering Handlers**: The `onRequest` method is used to register a handler for incoming requests. In this example, handlers respond to "authenticate" and "another-event" events.
185
185
-**Parameters**:
186
186
-`event`: The event name to listen for.
@@ -200,11 +200,19 @@ try {
200
200
### MicrostreamClientOptions
201
201
202
202
-`hubUrl`: URL of the Microstream Hub.
203
-
-`serviceName`: Name of the service connecting to the hub.
203
+
-`serviceName`: A Unique Service Registation Name of the service connecting to the hub.
204
204
-`timeout`: Timeout for requests in milliseconds (default: 5000).
205
205
-`heartbeatInterval`: Interval for sending heartbeats in milliseconds (default: 5000).
206
206
-[`logLevel`](#log-levels-): Log level for the client (default: "info").
207
207
208
+
### Important Notes 📝
209
+
210
+
-**Service names** must be **unique** across your entire system. The Hub will reject any connection attempts from services trying to register with an already registered name.
211
+
- If your service attempts to connect with a name that's already registered:
212
+
- The connection will be rejected
213
+
- An error will be thrown with code `DUPLICATE_SERVICE_REGISTRATION`
214
+
- The process will automatically terminate to prevent conflicts
0 commit comments