nestworker 2.1.6 → 2.1.7
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/README.md +684 -648
- package/dist/core/worker.interfaces.d.ts +38 -3
- package/dist/core/worker.module.js.map +1 -1
- package/dist/core/worker.pool.d.ts +52 -15
- package/dist/core/worker.pool.js +373 -216
- package/dist/core/worker.pool.js.map +1 -1
- package/dist/core/worker.service.d.ts +37 -3
- package/dist/core/worker.service.js +88 -16
- package/dist/core/worker.service.js.map +1 -1
- package/dist/di/di-serializer.js +24 -15
- package/dist/di/di-serializer.js.map +1 -1
- package/dist/di/worker-container.d.ts +24 -5
- package/dist/di/worker-container.js +70 -30
- package/dist/di/worker-container.js.map +1 -1
- package/dist/discovery/discovery.service.js +6 -15
- package/dist/discovery/discovery.service.js.map +1 -1
- package/dist/example/bench.js +8 -2
- package/dist/example/bench.js.map +1 -1
- package/dist/example/image.service.d.ts +8 -0
- package/dist/example/image.service.js +31 -0
- package/dist/example/image.service.js.map +1 -1
- package/dist/example/main.js +10 -2
- package/dist/example/main.js.map +1 -1
- package/dist/health/worker.health.js +3 -1
- package/dist/health/worker.health.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/metrics/worker.metrics.js +6 -1
- package/dist/metrics/worker.metrics.js.map +1 -1
- package/dist/worker/worker-runtime.js +81 -73
- package/dist/worker/worker-runtime.js.map +1 -1
- package/package.json +85 -82
|
@@ -6,13 +6,6 @@ const worker_container_1 = require("../di/worker-container");
|
|
|
6
6
|
const services = node_worker_threads_1.workerData?.services ?? [];
|
|
7
7
|
const container = new worker_container_1.WorkerContainer();
|
|
8
8
|
const instances = new Map();
|
|
9
|
-
// Index services by name so we can lazily reconstruct each one the first
|
|
10
|
-
// time a job for it arrives. Loading ALL services synchronously before
|
|
11
|
-
// sending `worker:ready` delays the pool from dispatching ANY work to this
|
|
12
|
-
// worker — which is catastrophic for cold-burst throughput when many
|
|
13
|
-
// workers spawn together. Lazy loading lets the pool start dispatching
|
|
14
|
-
// immediately; each service pays its `vm.runInContext` cost on its first
|
|
15
|
-
// invocation and is cached for every subsequent call.
|
|
16
9
|
const servicesByName = new Map();
|
|
17
10
|
for (const svc of services)
|
|
18
11
|
servicesByName.set(svc.name, svc);
|
|
@@ -28,42 +21,49 @@ function getInstance(name) {
|
|
|
28
21
|
instances.set(svc.name, inst);
|
|
29
22
|
return inst;
|
|
30
23
|
}
|
|
31
|
-
// Stash parentPort once — `parentPort` is a module getter; caching the
|
|
32
|
-
// reference avoids the getter call on every postMessage on the hot path.
|
|
33
24
|
const port = node_worker_threads_1.parentPort;
|
|
34
25
|
port.postMessage({ type: 'worker:ready' });
|
|
35
26
|
// ── Pending IPC calls ─────────────────────────────────────────────────────
|
|
36
27
|
const pendingIpc = new Map();
|
|
37
28
|
// ── Pending AbortControllers (keyed by abortSignalId) ────────────────────
|
|
38
29
|
const pendingAborts = new Map();
|
|
39
|
-
|
|
30
|
+
/**
|
|
31
|
+
* abortSignalId of the task currently being dispatched on this microtask.
|
|
32
|
+
* `buildProxy` reads it so that proxy IPC requests can forward the parent
|
|
33
|
+
* task's abort id to the main thread, allowing proxy methods to receive
|
|
34
|
+
* the originating AbortSignal as their last argument.
|
|
35
|
+
*
|
|
36
|
+
* Set in `runJob` immediately before invoking the task, cleared in the
|
|
37
|
+
* settle paths. Proxy calls scheduled synchronously inside the task body
|
|
38
|
+
* (or in micro/macrotasks chained off it) inherit this id automatically.
|
|
39
|
+
*/
|
|
40
|
+
let currentAbortId;
|
|
41
|
+
// ── ALS for context propagation ──────────────────────────────────────────
|
|
42
|
+
// The shape mirrors the WorkerModuleOptions.asyncLocalStorages array order.
|
|
43
|
+
// Stored as `unknown[]` (not `Record<string, unknown>`) so >10 storages
|
|
44
|
+
// work and the structuredClone payload is smaller.
|
|
40
45
|
const workerAls = new node_async_hooks_1.AsyncLocalStorage();
|
|
41
|
-
// Cache built proxies per descriptor signature — proxy descriptors are
|
|
42
|
-
// static per service, but the previous code rebuilt them on every job and
|
|
43
|
-
// mutated the shared service instance each time. Cache by propertyKey.
|
|
44
46
|
const proxyCache = new Map();
|
|
45
|
-
const proxiesInstalled = new
|
|
47
|
+
const proxiesInstalled = new WeakMap();
|
|
46
48
|
port.on('message', (msg) => {
|
|
47
49
|
const message = msg;
|
|
48
50
|
const t = message.type;
|
|
49
|
-
// IPC result from main thread
|
|
50
51
|
if (t === 'ipc:result') {
|
|
51
52
|
const res = message;
|
|
52
53
|
const pending = pendingIpc.get(res.callId);
|
|
53
54
|
if (!pending)
|
|
54
55
|
return;
|
|
55
56
|
pendingIpc.delete(res.callId);
|
|
56
|
-
res.ok
|
|
57
|
+
res.ok
|
|
58
|
+
? pending.resolve(res.data)
|
|
59
|
+
: pending.reject(new Error(res.error ?? 'IPC failed'));
|
|
57
60
|
return;
|
|
58
61
|
}
|
|
59
|
-
// Abort signal from main thread
|
|
60
62
|
if (t === 'abort') {
|
|
61
63
|
const abort = message;
|
|
62
64
|
pendingAborts.get(abort.abortSignalId)?.abort();
|
|
63
65
|
return;
|
|
64
66
|
}
|
|
65
|
-
// Batched jobs — process each. All sync-resolving results get auto-batched
|
|
66
|
-
// back into a single results envelope via the result flush microtask.
|
|
67
67
|
if (t === 'batch') {
|
|
68
68
|
const batch = message;
|
|
69
69
|
const jobs = batch.jobs;
|
|
@@ -75,15 +75,12 @@ port.on('message', (msg) => {
|
|
|
75
75
|
finally {
|
|
76
76
|
forceBuffer = false;
|
|
77
77
|
}
|
|
78
|
-
// Flush any sync results we accumulated during the loop as one envelope.
|
|
79
78
|
if (resultBuffer.length > 0) {
|
|
80
|
-
flushScheduled = true;
|
|
79
|
+
flushScheduled = true;
|
|
81
80
|
flushResults();
|
|
82
81
|
}
|
|
83
82
|
return;
|
|
84
83
|
}
|
|
85
|
-
// Single job — pool sends this when only one job was dispatched in the
|
|
86
|
-
// schedule pass (no batching benefit to wrap a 1-element envelope).
|
|
87
84
|
runJob(message);
|
|
88
85
|
});
|
|
89
86
|
function buildProxy(descriptor) {
|
|
@@ -103,6 +100,10 @@ function buildProxy(descriptor) {
|
|
|
103
100
|
methodName,
|
|
104
101
|
args,
|
|
105
102
|
};
|
|
103
|
+
// Propagate the originating task's abortSignalId so the main thread
|
|
104
|
+
// can supply a live AbortSignal to the proxy method implementation.
|
|
105
|
+
if (currentAbortId !== undefined)
|
|
106
|
+
request.abortSignalId = currentAbortId;
|
|
106
107
|
try {
|
|
107
108
|
port.postMessage(request);
|
|
108
109
|
}
|
|
@@ -116,24 +117,10 @@ function buildProxy(descriptor) {
|
|
|
116
117
|
proxyCache.set(descriptor.propertyKey, proxy);
|
|
117
118
|
return proxy;
|
|
118
119
|
}
|
|
119
|
-
// Counter-based call IDs — far cheaper than crypto.randomUUID() and only
|
|
120
|
-
// need to be unique within this worker process. Numeric IDs clone faster
|
|
121
|
-
// and hash cheaper than strings.
|
|
122
120
|
let __callCounter = 0;
|
|
123
121
|
// ── Outgoing result batching ─────────────────────────────────────────────
|
|
124
|
-
//
|
|
125
|
-
// We accumulate results into a single envelope per microtask tick. When a
|
|
126
|
-
// batch of jobs is dispatched at once, their resolved Promises all fire on
|
|
127
|
-
// the same microtask drain; the flush microtask is scheduled at the first
|
|
128
|
-
// postResult call and runs AFTER every queued .then, so it captures the
|
|
129
|
-
// entire batch and sends it in ONE postMessage. This collapses the per-job
|
|
130
|
-
// structuredClone fixed cost into a single per-batch one.
|
|
131
122
|
const resultBuffer = [];
|
|
132
123
|
let flushScheduled = false;
|
|
133
|
-
// When true, postResult always buffers (we're inside a batch loop and want
|
|
134
|
-
// every sync-resolved result of that batch to coalesce into one postMessage).
|
|
135
|
-
// When false (the steady-state concurrency=1 round-trip path), the FIRST
|
|
136
|
-
// result of the tick is posted immediately and only subsequent ones buffer.
|
|
137
124
|
let forceBuffer = false;
|
|
138
125
|
function scheduleFlush() {
|
|
139
126
|
if (flushScheduled)
|
|
@@ -152,18 +139,14 @@ function flushResults() {
|
|
|
152
139
|
port.postMessage(only);
|
|
153
140
|
return;
|
|
154
141
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
142
|
+
const batch = {
|
|
143
|
+
type: 'results',
|
|
144
|
+
results: resultBuffer.slice(0, n),
|
|
145
|
+
};
|
|
158
146
|
resultBuffer.length = 0;
|
|
159
147
|
port.postMessage(batch);
|
|
160
148
|
}
|
|
161
149
|
function postResult(res) {
|
|
162
|
-
// Fast path: outside any batch loop, no flush pending, buffer empty.
|
|
163
|
-
// This is the steady-state case for single-job dispatches (concurrency=1):
|
|
164
|
-
// sending immediately removes a full microtask hop from the round-trip.
|
|
165
|
-
// Any later results arriving in the SAME tick will queue and flush as
|
|
166
|
-
// a batch as usual.
|
|
167
150
|
if (!forceBuffer && !flushScheduled && resultBuffer.length === 0) {
|
|
168
151
|
port.postMessage(res);
|
|
169
152
|
return;
|
|
@@ -178,16 +161,18 @@ function runJob(job) {
|
|
|
178
161
|
postError(jobId, new Error(`Service "${job.serviceName}" is not registered`));
|
|
179
162
|
return;
|
|
180
163
|
}
|
|
181
|
-
// Inject proxy stubs the first time we see a (service, propertyKey) pair.
|
|
182
|
-
// Proxies are static per service — re-mutating per job was wasted work.
|
|
183
164
|
const proxyServices = job.proxyServices;
|
|
184
165
|
if (proxyServices !== undefined && proxyServices.length > 0) {
|
|
166
|
+
let installed = proxiesInstalled.get(inst);
|
|
167
|
+
if (!installed) {
|
|
168
|
+
installed = new Set();
|
|
169
|
+
proxiesInstalled.set(inst, installed);
|
|
170
|
+
}
|
|
185
171
|
for (let i = 0; i < proxyServices.length; i++) {
|
|
186
172
|
const d = proxyServices[i];
|
|
187
|
-
|
|
188
|
-
if (!proxiesInstalled.has(key)) {
|
|
173
|
+
if (!installed.has(d.propertyKey)) {
|
|
189
174
|
inst[d.propertyKey] = buildProxy(d);
|
|
190
|
-
|
|
175
|
+
installed.add(d.propertyKey);
|
|
191
176
|
}
|
|
192
177
|
}
|
|
193
178
|
}
|
|
@@ -198,50 +183,59 @@ function runJob(job) {
|
|
|
198
183
|
}
|
|
199
184
|
const abortSignalId = job.abortSignalId;
|
|
200
185
|
const args = job.args;
|
|
201
|
-
let abortController;
|
|
202
186
|
let callArgs = args;
|
|
203
187
|
if (abortSignalId !== undefined) {
|
|
204
|
-
abortController = new AbortController();
|
|
188
|
+
const abortController = new AbortController();
|
|
205
189
|
pendingAborts.set(abortSignalId, abortController);
|
|
206
190
|
callArgs = [...args, abortController.signal];
|
|
207
191
|
}
|
|
192
|
+
const settle = () => {
|
|
193
|
+
if (abortSignalId !== undefined)
|
|
194
|
+
pendingAborts.delete(abortSignalId);
|
|
195
|
+
if (currentAbortId === abortSignalId)
|
|
196
|
+
currentAbortId = undefined;
|
|
197
|
+
};
|
|
198
|
+
// Track the active task's abort id so synchronously-launched proxy calls
|
|
199
|
+
// can forward it. Restored after the synchronous portion of the task runs.
|
|
200
|
+
const prevAbortId = currentAbortId;
|
|
201
|
+
currentAbortId = abortSignalId;
|
|
208
202
|
try {
|
|
209
203
|
const alsContext = job.alsContext;
|
|
210
|
-
// Common path: no ALS — call fn directly with `inst` as `this`.
|
|
211
204
|
let result;
|
|
212
205
|
if (alsContext === undefined) {
|
|
213
|
-
// .apply is faster than spread when callArgs is the original array,
|
|
214
|
-
// and avoids an allocation on the no-abort path.
|
|
215
206
|
result = fn.apply(inst, callArgs);
|
|
216
207
|
}
|
|
217
208
|
else {
|
|
218
209
|
result = workerAls.run(alsContext, () => fn.apply(inst, callArgs));
|
|
219
210
|
}
|
|
220
|
-
// Sync fast path: avoid Promise allocation + microtask roundtrip when
|
|
221
|
-
// the task returned a plain value.
|
|
222
211
|
if (result === null ||
|
|
223
212
|
typeof result !== 'object' ||
|
|
224
213
|
typeof result.then !== 'function') {
|
|
225
|
-
|
|
226
|
-
pendingAborts.delete(abortSignalId);
|
|
214
|
+
settle();
|
|
227
215
|
postResult({ type: 'result', ok: true, data: result, jobId });
|
|
228
216
|
return;
|
|
229
217
|
}
|
|
218
|
+
// Async return — keep currentAbortId set across the .then so proxy calls
|
|
219
|
+
// scheduled in microtasks chained off the task body still see it.
|
|
220
|
+
// (`currentAbortId` is only used synchronously by proxy methods at the
|
|
221
|
+
// moment they are CALLED, not when they postMessage.)
|
|
230
222
|
result.then((data) => {
|
|
231
|
-
|
|
232
|
-
pendingAborts.delete(abortSignalId);
|
|
223
|
+
settle();
|
|
233
224
|
postResult({ type: 'result', ok: true, data, jobId });
|
|
234
225
|
}, (error) => {
|
|
235
|
-
|
|
236
|
-
pendingAborts.delete(abortSignalId);
|
|
226
|
+
settle();
|
|
237
227
|
postError(jobId, error);
|
|
238
228
|
});
|
|
239
229
|
}
|
|
240
230
|
catch (error) {
|
|
241
|
-
|
|
242
|
-
pendingAborts.delete(abortSignalId);
|
|
231
|
+
settle();
|
|
243
232
|
postError(jobId, error);
|
|
244
233
|
}
|
|
234
|
+
finally {
|
|
235
|
+
// Restore the outer abort id so back-to-back synchronous runJob calls
|
|
236
|
+
// (from a batch) don't leak ids into each other's proxy invocations.
|
|
237
|
+
currentAbortId = prevAbortId;
|
|
238
|
+
}
|
|
245
239
|
}
|
|
246
240
|
function postError(jobId, error) {
|
|
247
241
|
const e = error;
|
|
@@ -263,16 +257,30 @@ function serializeExtraProps(err) {
|
|
|
263
257
|
for (const key of Object.keys(err)) {
|
|
264
258
|
if (skip.has(key))
|
|
265
259
|
continue;
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
260
|
+
extra[key] = err[key];
|
|
261
|
+
hasExtra = true;
|
|
262
|
+
}
|
|
263
|
+
if (!hasExtra)
|
|
264
|
+
return undefined;
|
|
265
|
+
try {
|
|
266
|
+
structuredClone(extra);
|
|
267
|
+
return extra;
|
|
268
|
+
}
|
|
269
|
+
catch {
|
|
270
|
+
const safe = {};
|
|
271
|
+
let kept = false;
|
|
272
|
+
for (const key of Object.keys(extra)) {
|
|
273
|
+
try {
|
|
274
|
+
structuredClone(extra[key]);
|
|
275
|
+
safe[key] = extra[key];
|
|
276
|
+
kept = true;
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
/* skip */
|
|
280
|
+
}
|
|
273
281
|
}
|
|
282
|
+
return kept ? safe : undefined;
|
|
274
283
|
}
|
|
275
|
-
return hasExtra ? extra : undefined;
|
|
276
284
|
}
|
|
277
285
|
const SKIP_ERR_KEYS = new Set(['name', 'message', 'stack', 'code']);
|
|
278
286
|
//# sourceMappingURL=worker-runtime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-runtime.js","sourceRoot":"","sources":["../../src/worker/worker-runtime.ts"],"names":[],"mappings":";;AAAA,6DAA6D;AAC7D,uDAAqD;AACrD,6DAAyD;AAezD,MAAM,QAAQ,GAAwB,gCAAU,EAAE,QAAQ,IAAI,EAAE,CAAC;AACjE,MAAM,SAAS,GAAG,IAAI,kCAAe,EAAE,CAAC;AAIxC,MAAM,SAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;AACrD,
|
|
1
|
+
{"version":3,"file":"worker-runtime.js","sourceRoot":"","sources":["../../src/worker/worker-runtime.ts"],"names":[],"mappings":";;AAAA,6DAA6D;AAC7D,uDAAqD;AACrD,6DAAyD;AAezD,MAAM,QAAQ,GAAwB,gCAAU,EAAE,QAAQ,IAAI,EAAE,CAAC;AACjE,MAAM,SAAS,GAAG,IAAI,kCAAe,EAAE,CAAC;AAIxC,MAAM,SAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;AACrD,MAAM,cAAc,GAAG,IAAI,GAAG,EAA6B,CAAC;AAC5D,KAAK,MAAM,GAAG,IAAI,QAAQ;IAAE,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAE9D,SAAS,WAAW,CAAC,IAAY;IAC/B,IAAI,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,IA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I,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QAC5B,KAAK,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QACtB,QAAQ,GAAG,IAAI,CAAC;IAClB,CAAC;IACD,IAAI,CAAC,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChC,IAAI,CAAC;QACH,eAAe,CAAC,KAAK,CAAC,CAAC;QACvB,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,GAA4B,EAAE,CAAC;QACzC,IAAI,IAAI,GAAG,KAAK,CAAC;QACjB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,IAAI,CAAC;gBACH,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC5B,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;gBACvB,IAAI,GAAG,IAAI,CAAC;YACd,CAAC;YAAC,MAAM,CAAC;gBACP,UAAU;YACZ,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IACjC,CAAC;AACH,CAAC;AAED,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,82 +1,85 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "nestworker",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"description": "Enterprise-grade worker thread module for NestJS — priority pool, auto-discovery, DI in workers",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"require": "./dist/index.js",
|
|
11
|
-
"default": "./dist/index.js"
|
|
12
|
-
},
|
|
13
|
-
"./package.json": "./package.json"
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist",
|
|
17
|
-
"README.md",
|
|
18
|
-
"LICENSE"
|
|
19
|
-
],
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "tsc -p tsconfig.build.json",
|
|
22
|
-
"build:watch": "tsc -p tsconfig.build.json --watch",
|
|
23
|
-
"example": "npm run build && node dist/example/main.js",
|
|
24
|
-
"bench": "npm run build && node dist/example/bench.js",
|
|
25
|
-
"test": "npm run build && jest",
|
|
26
|
-
"test:unit": "jest",
|
|
27
|
-
"lint": "eslint \"{src,test}/**/*.ts\"",
|
|
28
|
-
"lint:fix": "eslint \"{src,test}/**/*.ts\" --fix",
|
|
29
|
-
"format": "prettier --write
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"@
|
|
62
|
-
"@
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
65
|
-
"
|
|
66
|
-
"eslint-
|
|
67
|
-
"eslint
|
|
68
|
-
"
|
|
69
|
-
"prettier": "^
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
},
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "nestworker",
|
|
3
|
+
"version": "2.1.7",
|
|
4
|
+
"description": "Enterprise-grade worker thread module for NestJS — priority pool, auto-discovery, DI in workers",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -p tsconfig.build.json",
|
|
22
|
+
"build:watch": "tsc -p tsconfig.build.json --watch",
|
|
23
|
+
"example": "npm run build && node dist/example/main.js",
|
|
24
|
+
"bench": "npm run build && node dist/example/bench.js",
|
|
25
|
+
"test": "npm run build && jest",
|
|
26
|
+
"test:unit": "jest",
|
|
27
|
+
"lint": "eslint \"{src,test}/**/*.ts\"",
|
|
28
|
+
"lint:fix": "eslint \"{src,test}/**/*.ts\" --fix",
|
|
29
|
+
"format": "prettier --write .",
|
|
30
|
+
"format:check": "prettier --check .",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"check": "npm run typecheck && npm run lint && npm run test",
|
|
33
|
+
"prepublishOnly": "npm run format && npm run format:check && npm run check && npm run build"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"nestjs",
|
|
37
|
+
"worker",
|
|
38
|
+
"worker-threads",
|
|
39
|
+
"thread-pool",
|
|
40
|
+
"cpu",
|
|
41
|
+
"parallel",
|
|
42
|
+
"offload",
|
|
43
|
+
"typescript",
|
|
44
|
+
"node",
|
|
45
|
+
"workers",
|
|
46
|
+
"thread",
|
|
47
|
+
"multithreading",
|
|
48
|
+
"backend"
|
|
49
|
+
],
|
|
50
|
+
"author": "Vahe Hakobyan",
|
|
51
|
+
"license": "MIT",
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=16.0.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
57
|
+
"@nestjs/core": "^10.0.0 || ^11.0.0",
|
|
58
|
+
"reflect-metadata": "^0.1.0 || ^0.2.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@nestjs/common": "^11.1.21",
|
|
62
|
+
"@nestjs/core": "^11.1.21",
|
|
63
|
+
"@nestjs/testing": "^11.1.24",
|
|
64
|
+
"@types/jest": "^30.0.0",
|
|
65
|
+
"@types/node": "^22.0.0",
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
67
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
68
|
+
"eslint": "^8.57.0",
|
|
69
|
+
"eslint-config-prettier": "^10.1.8",
|
|
70
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
71
|
+
"jest": "^30.4.2",
|
|
72
|
+
"prettier": "^3.8.3",
|
|
73
|
+
"reflect-metadata": "^0.2.2",
|
|
74
|
+
"ts-jest": "^29.4.11",
|
|
75
|
+
"typescript": "^5.6.0"
|
|
76
|
+
},
|
|
77
|
+
"bugs": {
|
|
78
|
+
"url": "https://github.com/VaheHak/nestworker/issues"
|
|
79
|
+
},
|
|
80
|
+
"homepage": "https://github.com/VaheHak/nestworker#readme",
|
|
81
|
+
"repository": {
|
|
82
|
+
"type": "git",
|
|
83
|
+
"url": "https://github.com/VaheHak/nestworker.git"
|
|
84
|
+
}
|
|
85
|
+
}
|