smart-stick-loadbalancer 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +43 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -25,12 +25,21 @@ npm install smart-stick-loadbalancer
25
25
  ## Example Configuration (`config.json`)
26
26
 
27
27
  ```json
28
- module.exports = {
29
28
  {
30
29
  "port": 3001,
31
30
  "backends": [
32
- { "id": 0, "url": "http://localhost:5000", "owner": "example@example.com", "weight": 1 },
33
- { "id": 1, "url": "http://localhost:5001", "owner": "example@example.com", "weight": 1 }
31
+ {
32
+ "id": 0,
33
+ "url": "http://localhost:5000",
34
+ "owner": "example@example.com",
35
+ "weight": 1
36
+ },
37
+ {
38
+ "id": 1,
39
+ "url": "http://localhost:5001",
40
+ "owner": "example@example.com",
41
+ "weight": 1
42
+ }
34
43
  ],
35
44
  "health": { "interval": 10000, "timeout": 2000 },
36
45
  "email": {
@@ -38,7 +47,6 @@ module.exports = {
38
47
  "auth": { "user": "<your-email@gmail.com>", "pass": "<your-app-password>" }
39
48
  }
40
49
  }
41
- };
42
50
  ```
43
51
 
44
52
  ---
@@ -59,6 +67,37 @@ lb.start(); // starts the load balancer
59
67
 
60
68
  ---
61
69
 
70
+ ## Quick Start Demo
71
+
72
+ Create two simple backend servers:
73
+
74
+ // server5000.js
75
+ const express = require('express');
76
+ const app = express();
77
+ app.get('/', (req, res) => res.send('Hello from 5000'));
78
+ app.listen(5000, () => console.log('Server 5000 running'));
79
+
80
+ // server5001.js
81
+ const express = require('express');
82
+ const app = express();
83
+ app.get('/', (req, res) => res.send('Hello from 5001'));
84
+ app.listen(5001, () => console.log('Server 5001 running'));
85
+
86
+ Start the load balancer:
87
+
88
+ ```
89
+ node index.js
90
+ ```
91
+
92
+ Open in browser: http://localhost:3001
93
+ Requests should alternate between the two backends (sticky sessions maintained per client).
94
+
95
+ Check health status:
96
+
97
+ ```
98
+ curl http://localhost:3001/_lb/health
99
+ ```
100
+
62
101
  ## Health Endpoint
63
102
 
64
103
  ```http
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-stick-loadbalancer",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A lightweight sticky-session load balancer for Node.js with health checks and optional email alerts.",
5
5
  "main": "src/index.js",
6
6
  "bin": {