Skip to content

Commit 913a408

Browse files
committed
docs(readme): Update README with enhanced logging details and usage examples
This commit updates the README file to include details about the enhanced logging functionality in the microstream-client SDK. It provides information on the new logLevel option, color-coded log messages, and usage examples. Changes include: - Addition of logLevel details in the Configuration Options section. - Updated usage examples to demonstrate the new logging functionality. - Improved readability and structure of the README. This update ensures that developers have clear and comprehensive documentation on how to use the enhanced logging features in the microstream-client SDK.
1 parent 6651ad9 commit 913a408

File tree

1 file changed

+57
-26
lines changed

1 file changed

+57
-26
lines changed

README.md

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# MicroStream Client SDK
1+
# MicroStream Client SDK 🚀
22

33
The client library for Microstream, a lightweight, real-time communication library for microservices. Replace REST/gRPC with WebSockets for event-driven messaging. Simplifies inter-service communication with a request-response pattern and automatic reconnection.
44

@@ -40,73 +40,95 @@ License: [MIT](./LICENSE)
4040

4141
<hr>
4242

43-
## Table of Contents
43+
## Table of Contents 📚
4444

45-
- [Features](#features)
46-
- [Installation](#installation)
47-
- [Usage](#usage)
48-
- [Configuration Options](#configuration-options)
49-
- [Log Levels](#log-levels)
50-
- [Author](#author)
51-
- [Contributing](#contributing)
52-
- [License](#license)
45+
- [Features ✨](#features-✨)
46+
- [Installation 🛠️](#installation-🛠️)
47+
- [Usage 🚀](#usage-🚀)
48+
- [Configuration Options ⚙️](#configuration-options-⚙️)
49+
- [Log Levels 📊](#log-levels-📊)
50+
- [MicroStream Hub 🏢](#microstream-hub-🏢)
51+
- [Author 👨‍💻](#author-👨‍💻)
52+
- [Contributing 🤝](#contributing-🤝)
53+
- [License 📜](#license-📜)
5354

5455
<hr>
5556

56-
## Features
57+
## Features
5758

58-
- Real-time inter-service communication using WebSockets.
59-
- Synchronous request-response pattern without HTTP overhead.
60-
- Auto-discovery and connection management.
61-
- Configurable logging for better observability.
59+
- 🔄 Real-time inter-service communication using WebSockets.
60+
- ⚡ Synchronous request-response pattern without HTTP overhead.
61+
- 🔍 Auto-discovery and connection management.
62+
- 📊 Configurable logging for better observability.
63+
- 🏢 Central WebSocket server for real-time communication between microservices (provided by the hub).
64+
- 🔗 Service discovery and registration (provided by the hub).
65+
- 📡 Request routing and response handling (provided by the hub).
66+
- ❤️ Heartbeat mechanism to detect and remove inactive services (provided by the hub).
6267

6368
<hr>
6469

65-
## Installation
70+
## Installation 🛠️
6671

6772
```bash
6873
npm install microstream-client
6974
```
7075

7176
<hr>
7277

73-
## Usage
78+
## Usage 🚀
7479

7580
```typescript
7681
import { MicrostreamClient } from "microstream-client";
7782

83+
// Create a new MicrostreamClient instance with the necessary configuration
7884
const client = new MicrostreamClient({
79-
hubUrl: "http://localhost:3000",
80-
serviceName: "auth-service",
85+
hubUrl: "http://localhost:3000", // URL of the Microstream Hub
86+
serviceName: "auth-service", // Name of your service
8187
logLevel: "debug", // Enable debug logs
8288
});
8389

90+
// Register a handler for incoming requests
8491
client.onRequest("authenticate", (data) => {
8592
console.log("Received authentication request:", data);
86-
return { success: true, token: "sample-token" };
93+
return { success: true, token: "sample-token" }; // Respond to the request
8794
});
8895

96+
// Send a request to another service and handle the response
8997
const response = await client.sendRequest("jwt-service", "generate_jwt", {
9098
userId: 123,
9199
});
92100
console.log("Received response:", response);
93101
```
94102

103+
### Explanation
104+
105+
1. **Configuration**: The [`MicrostreamClient`](#microstreamclientoptions) is configured with the URL of the Microstream Hub, the name of your service, and the log level.
106+
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.
107+
- **Parameters**:
108+
- `event`: The event name to listen for.
109+
- `handler`: The function to handle the request. It receives the request data and returns the response.
110+
3. **Sending Requests**: The `sendRequest` method is used to send a request to another service. In this example, a request is sent to the "jwt-service" to generate a JWT for a user with ID 123.
111+
- **Parameters**:
112+
- `targetService`: The name of the target service.
113+
- `event`: The event name to trigger on the target service.
114+
- `data`: Optional data to send with the request.
115+
- **Returns**: A promise that resolves with the response from the target service.
116+
95117
<hr>
96118

97-
## Configuration Options
119+
## Configuration Options ⚙️
98120

99121
### MicrostreamClientOptions
100122

101123
- `hubUrl`: URL of the Microstream Hub.
102124
- `serviceName`: Name of the service connecting to the hub.
103125
- `timeout`: Timeout for requests in milliseconds (default: 5000).
104126
- `heartbeatInterval`: Interval for sending heartbeats in milliseconds (default: 5000).
105-
- `logLevel`: Log level for the client (default: "info").
127+
- [`logLevel`](#log-levels-): Log level for the client (default: "info").
106128

107129
<hr>
108130

109-
## Log Levels
131+
## Log Levels 📊
110132

111133
- `debug`: Log everything (useful for development).
112134
- `info`: Log info, warnings, and errors.
@@ -116,7 +138,16 @@ console.log("Received response:", response);
116138

117139
<hr>
118140

119-
## Author
141+
## MicroStream Hub 🏢
142+
143+
We also provide a central hub for easy integration with the MicroStream Client SDK.
144+
145+
- [MicroStream Hub on GitHub](https://github.com/arijitcodes/microstream-hub)
146+
- [MicroStream Hub Documentation](https://github.com/arijitcodes/microstream-hub#readme)
147+
148+
<hr>
149+
150+
## Author 👨‍💻
120151

121152
Author: [Arijit Banerjee](https://www.github.com/arijitcodes)
122153

@@ -135,13 +166,13 @@ Email: [email protected]
135166

136167
<hr>
137168

138-
## Contributing
169+
## Contributing 🤝
139170

140171
We welcome contributions! Please see our [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on how to contribute to this project.
141172

142173
<hr>
143174

144-
## License
175+
## License 📜
145176

146177
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
147178

0 commit comments

Comments
 (0)