node-runtime-guardian 0.1.0
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.
- package/LICENSE +22 -0
- package/README.md +423 -0
- package/dist/core/EventLoopMonitor.d.ts +32 -0
- package/dist/core/EventLoopMonitor.d.ts.map +1 -0
- package/dist/core/EventLoopMonitor.js +131 -0
- package/dist/core/EventLoopMonitor.js.map +1 -0
- package/dist/core/GCMonitor.d.ts +32 -0
- package/dist/core/GCMonitor.d.ts.map +1 -0
- package/dist/core/GCMonitor.js +151 -0
- package/dist/core/GCMonitor.js.map +1 -0
- package/dist/core/Guardian.d.ts +76 -0
- package/dist/core/Guardian.d.ts.map +1 -0
- package/dist/core/Guardian.js +196 -0
- package/dist/core/Guardian.js.map +1 -0
- package/dist/core/HeuristicEngine.d.ts +27 -0
- package/dist/core/HeuristicEngine.d.ts.map +1 -0
- package/dist/core/HeuristicEngine.js +150 -0
- package/dist/core/HeuristicEngine.js.map +1 -0
- package/dist/core/MemoryMonitor.d.ts +33 -0
- package/dist/core/MemoryMonitor.d.ts.map +1 -0
- package/dist/core/MemoryMonitor.js +193 -0
- package/dist/core/MemoryMonitor.js.map +1 -0
- package/dist/core/ProtectionLayer.d.ts +42 -0
- package/dist/core/ProtectionLayer.d.ts.map +1 -0
- package/dist/core/ProtectionLayer.js +105 -0
- package/dist/core/ProtectionLayer.js.map +1 -0
- package/dist/core/ThreadPoolMonitor.d.ts +29 -0
- package/dist/core/ThreadPoolMonitor.d.ts.map +1 -0
- package/dist/core/ThreadPoolMonitor.js +144 -0
- package/dist/core/ThreadPoolMonitor.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/Plugin.d.ts +53 -0
- package/dist/plugins/Plugin.d.ts.map +1 -0
- package/dist/plugins/Plugin.js +74 -0
- package/dist/plugins/Plugin.js.map +1 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +18 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/server/MetricsServer.d.ts +26 -0
- package/dist/server/MetricsServer.d.ts.map +1 -0
- package/dist/server/MetricsServer.js +86 -0
- package/dist/server/MetricsServer.js.map +1 -0
- package/dist/types/index.d.ts +104 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/metrics.d.ts +67 -0
- package/dist/types/metrics.d.ts.map +1 -0
- package/dist/types/metrics.js +3 -0
- package/dist/types/metrics.js.map +1 -0
- package/dist/worker/WorkerPool.d.ts +44 -0
- package/dist/worker/WorkerPool.d.ts.map +1 -0
- package/dist/worker/WorkerPool.js +214 -0
- package/dist/worker/WorkerPool.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkerPool = void 0;
|
|
4
|
+
const worker_threads_1 = require("worker_threads");
|
|
5
|
+
/**
|
|
6
|
+
* Managed worker thread pool with queue management
|
|
7
|
+
*/
|
|
8
|
+
class WorkerPool {
|
|
9
|
+
constructor(workerScript, config = {}) {
|
|
10
|
+
this.workers = [];
|
|
11
|
+
this.queue = [];
|
|
12
|
+
this.activeTasks = new Map();
|
|
13
|
+
this.workerTaskMap = new Map(); // Track which worker handles which task
|
|
14
|
+
this.isShuttingDown = false;
|
|
15
|
+
this.workerScript = workerScript;
|
|
16
|
+
this.config = {
|
|
17
|
+
enabled: config.enabled ?? true,
|
|
18
|
+
poolSize: config.poolSize ?? 4,
|
|
19
|
+
maxQueueSize: config.maxQueueSize ?? 100,
|
|
20
|
+
};
|
|
21
|
+
if (this.config.enabled) {
|
|
22
|
+
this.initializeWorkers();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Run a task in the worker pool
|
|
27
|
+
*/
|
|
28
|
+
async run(data) {
|
|
29
|
+
if (!this.config.enabled) {
|
|
30
|
+
throw new Error('Worker pool is not enabled');
|
|
31
|
+
}
|
|
32
|
+
if (this.isShuttingDown) {
|
|
33
|
+
throw new Error('Worker pool is shutting down');
|
|
34
|
+
}
|
|
35
|
+
// Check queue size
|
|
36
|
+
if (this.queue.length >= this.config.maxQueueSize) {
|
|
37
|
+
throw new Error(`Worker pool queue is full (${this.config.maxQueueSize} tasks)`);
|
|
38
|
+
}
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
const task = {
|
|
41
|
+
id: `${Date.now()}-${Math.random()}`,
|
|
42
|
+
data,
|
|
43
|
+
resolve,
|
|
44
|
+
reject,
|
|
45
|
+
};
|
|
46
|
+
this.queue.push(task);
|
|
47
|
+
this.processQueue();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get current queue size
|
|
52
|
+
*/
|
|
53
|
+
getQueueSize() {
|
|
54
|
+
return this.queue.length;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get number of active tasks
|
|
58
|
+
*/
|
|
59
|
+
getActiveTasks() {
|
|
60
|
+
return this.activeTasks.size;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get pool statistics
|
|
64
|
+
*/
|
|
65
|
+
getStats() {
|
|
66
|
+
return {
|
|
67
|
+
poolSize: this.workers.length,
|
|
68
|
+
activeTasks: this.activeTasks.size,
|
|
69
|
+
queueSize: this.queue.length,
|
|
70
|
+
availableWorkers: this.workers.filter((w) => !this.isWorkerBusy(w))
|
|
71
|
+
.length,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Shutdown the worker pool
|
|
76
|
+
*/
|
|
77
|
+
async shutdown() {
|
|
78
|
+
this.isShuttingDown = true;
|
|
79
|
+
// Reject all queued tasks
|
|
80
|
+
while (this.queue.length > 0) {
|
|
81
|
+
const task = this.queue.shift();
|
|
82
|
+
if (task) {
|
|
83
|
+
task.reject(new Error('Worker pool is shutting down'));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Wait for active tasks to complete (with timeout)
|
|
87
|
+
const activeTaskPromises = Array.from(this.activeTasks.values()).map((task) => new Promise((resolve) => {
|
|
88
|
+
let checkInterval = null;
|
|
89
|
+
let timeoutId = null;
|
|
90
|
+
const cleanup = () => {
|
|
91
|
+
if (checkInterval) {
|
|
92
|
+
clearInterval(checkInterval);
|
|
93
|
+
checkInterval = null;
|
|
94
|
+
}
|
|
95
|
+
if (timeoutId) {
|
|
96
|
+
clearTimeout(timeoutId);
|
|
97
|
+
timeoutId = null;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
checkInterval = setInterval(() => {
|
|
101
|
+
if (!this.activeTasks.has(task.id)) {
|
|
102
|
+
cleanup();
|
|
103
|
+
resolve();
|
|
104
|
+
}
|
|
105
|
+
}, 100);
|
|
106
|
+
// Timeout after 5 seconds (reduced from 30 for faster test cleanup)
|
|
107
|
+
timeoutId = setTimeout(() => {
|
|
108
|
+
cleanup();
|
|
109
|
+
resolve();
|
|
110
|
+
}, 5000);
|
|
111
|
+
}));
|
|
112
|
+
await Promise.all(activeTaskPromises);
|
|
113
|
+
// Terminate all workers with a timeout
|
|
114
|
+
const terminatePromises = this.workers.map((worker) => {
|
|
115
|
+
const terminatePromise = Promise.resolve(worker.terminate()).catch(() => {
|
|
116
|
+
// Ignore errors if worker is already terminated
|
|
117
|
+
});
|
|
118
|
+
return Promise.race([
|
|
119
|
+
terminatePromise,
|
|
120
|
+
new Promise((resolve) => {
|
|
121
|
+
setTimeout(() => {
|
|
122
|
+
// Timeout reached, resolve anyway (worker may still be terminating)
|
|
123
|
+
resolve();
|
|
124
|
+
}, 2000);
|
|
125
|
+
}),
|
|
126
|
+
]);
|
|
127
|
+
});
|
|
128
|
+
await Promise.all(terminatePromises);
|
|
129
|
+
this.workers = [];
|
|
130
|
+
this.queue = [];
|
|
131
|
+
this.activeTasks.clear();
|
|
132
|
+
this.workerTaskMap.clear();
|
|
133
|
+
}
|
|
134
|
+
initializeWorkers() {
|
|
135
|
+
for (let i = 0; i < this.config.poolSize; i++) {
|
|
136
|
+
this.createWorker();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
createWorker() {
|
|
140
|
+
const worker = new worker_threads_1.Worker(this.workerScript);
|
|
141
|
+
worker.on('message', (message) => {
|
|
142
|
+
const task = this.activeTasks.get(message.id);
|
|
143
|
+
if (task) {
|
|
144
|
+
this.activeTasks.delete(message.id);
|
|
145
|
+
this.workerTaskMap.delete(worker);
|
|
146
|
+
if (message.error) {
|
|
147
|
+
const errorMessage = message.error instanceof Error
|
|
148
|
+
? message.error.message
|
|
149
|
+
: String(message.error);
|
|
150
|
+
task.reject(new Error(errorMessage));
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
task.resolve(message.result);
|
|
154
|
+
}
|
|
155
|
+
// Process next task in queue
|
|
156
|
+
this.processQueue();
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
worker.on('error', (error) => {
|
|
160
|
+
console.error('Worker error:', error);
|
|
161
|
+
// Remove worker and create a new one
|
|
162
|
+
const index = this.workers.indexOf(worker);
|
|
163
|
+
if (index > -1) {
|
|
164
|
+
this.workers.splice(index, 1);
|
|
165
|
+
this.createWorker();
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
worker.on('exit', (code) => {
|
|
169
|
+
if (code !== 0 && !this.isShuttingDown) {
|
|
170
|
+
// Worker crashed, replace it
|
|
171
|
+
const index = this.workers.indexOf(worker);
|
|
172
|
+
if (index > -1) {
|
|
173
|
+
this.workers.splice(index, 1);
|
|
174
|
+
this.createWorker();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
this.workers.push(worker);
|
|
179
|
+
return worker;
|
|
180
|
+
}
|
|
181
|
+
processQueue() {
|
|
182
|
+
if (this.isShuttingDown || this.queue.length === 0) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const availableWorker = this.workers.find((w) => !this.isWorkerBusy(w));
|
|
186
|
+
if (!availableWorker) {
|
|
187
|
+
return; // All workers are busy
|
|
188
|
+
}
|
|
189
|
+
const task = this.queue.shift();
|
|
190
|
+
if (!task) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
this.activeTasks.set(task.id, task);
|
|
194
|
+
this.workerTaskMap.set(availableWorker, task.id);
|
|
195
|
+
try {
|
|
196
|
+
availableWorker.postMessage({
|
|
197
|
+
id: task.id,
|
|
198
|
+
data: task.data,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
this.activeTasks.delete(task.id);
|
|
203
|
+
this.workerTaskMap.delete(availableWorker);
|
|
204
|
+
task.reject(error);
|
|
205
|
+
this.processQueue();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
isWorkerBusy(worker) {
|
|
209
|
+
// A worker is busy if it has an active task assigned to it
|
|
210
|
+
return this.workerTaskMap.has(worker);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
exports.WorkerPool = WorkerPool;
|
|
214
|
+
//# sourceMappingURL=WorkerPool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkerPool.js","sourceRoot":"","sources":["../../src/worker/WorkerPool.ts"],"names":[],"mappings":";;;AAAA,mDAAwC;AAUxC;;GAEG;AACH,MAAa,UAAU;IASrB,YAAY,YAAoB,EAAE,SAA2B,EAAE;QARvD,YAAO,GAAa,EAAE,CAAC;QACvB,UAAK,GAA6B,EAAE,CAAC;QACrC,gBAAW,GAAwC,IAAI,GAAG,EAAE,CAAC;QAC7D,kBAAa,GAAwB,IAAI,GAAG,EAAE,CAAC,CAAC,wCAAwC;QAGxF,mBAAc,GAAG,KAAK,CAAC;QAG7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IA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ED,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QAChC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO;QACT,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAEjD,IAAI,CAAC;YACH,eAAe,CAAC,WAAW,CAAC;gBAC1B,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACjC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;YAC3C,IAAI,CAAC,MAAM,CAAC,KAAc,CAAC,CAAC;YAC5B,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,CAAC;IACH,CAAC;IAEO,YAAY,CAAC,MAAc;QACjC,2DAA2D;QAC3D,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;CACF;AAxPD,gCAwPC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "node-runtime-guardian",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Production-grade runtime health and protection engine for Node.js applications",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc -p tsconfig.build.json",
|
|
9
|
+
"dev": "tsc -p tsconfig.build.json --watch",
|
|
10
|
+
"test": "jest",
|
|
11
|
+
"test:watch": "jest --watch",
|
|
12
|
+
"test:coverage": "jest --coverage",
|
|
13
|
+
"lint": "eslint src tests --ext .ts",
|
|
14
|
+
"lint:fix": "eslint src tests --ext .ts --fix",
|
|
15
|
+
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\" \"*.md\"",
|
|
16
|
+
"format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\" \"*.md\""
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"nodejs",
|
|
20
|
+
"runtime",
|
|
21
|
+
"monitoring",
|
|
22
|
+
"performance",
|
|
23
|
+
"health",
|
|
24
|
+
"event-loop",
|
|
25
|
+
"memory",
|
|
26
|
+
"gc",
|
|
27
|
+
"thread-pool"
|
|
28
|
+
],
|
|
29
|
+
"author": "Zeeshan Ashraf <https://github.com/Zeeshan-2k1>",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=16.0.0"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE"
|
|
38
|
+
],
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/Zeeshan-2k1/node-runtime-guardian"
|
|
42
|
+
},
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/Zeeshan-2k1/node-runtime-guardian/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/Zeeshan-2k1/node-runtime-guardian#readme",
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/jest": "^29.5.12",
|
|
49
|
+
"@types/node": "^24.0.0",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
51
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
52
|
+
"eslint": "^8.56.0",
|
|
53
|
+
"eslint-config-prettier": "^9.1.0",
|
|
54
|
+
"eslint-plugin-node": "^11.1.0",
|
|
55
|
+
"husky": "^9.0.11",
|
|
56
|
+
"jest": "^29.7.0",
|
|
57
|
+
"jest-util": "^30.2.0",
|
|
58
|
+
"lint-staged": "^15.2.0",
|
|
59
|
+
"prettier": "^3.2.5",
|
|
60
|
+
"ts-jest": "^29.1.2",
|
|
61
|
+
"typescript": "^5.3.3"
|
|
62
|
+
}
|
|
63
|
+
}
|