Skip to content

Commit 170ec7b

Browse files
committed
docs(readme): Added service registration name uniqueness requirements
- Added Important Notes section under Configuration Options - Documented service name uniqueness requirement - Added error handling details for duplicate registration - Documented automatic process termination behavior - Enhanced configuration documentation clarity
1 parent fde72fe commit 170ec7b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ const { MicrostreamClient } = require("microstream-client");
139139
// Create a new MicrostreamClient instance with the necessary configuration
140140
const client = new MicrostreamClient({
141141
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
143143
logLevel: "debug", // Enable debug logs
144144
});
145145

@@ -180,7 +180,7 @@ try {
180180

181181
### Explanation 👨🏻‍🏫
182182

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.
184184
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.
185185
- **Parameters**:
186186
- `event`: The event name to listen for.
@@ -200,11 +200,19 @@ try {
200200
### MicrostreamClientOptions
201201

202202
- `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.
204204
- `timeout`: Timeout for requests in milliseconds (default: 5000).
205205
- `heartbeatInterval`: Interval for sending heartbeats in milliseconds (default: 5000).
206206
- [`logLevel`](#log-levels-): Log level for the client (default: "info").
207207

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
215+
208216
<hr>
209217

210218
## Log Levels 📊

0 commit comments

Comments
 (0)