fluxion-ts 0.6.1 → 0.8.2
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 +69 -25
- package/dist/index.cjs +2 -5487
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +233 -0
- package/dist/index.d.mts +233 -0
- package/dist/index.mjs +2 -5465
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -26
- package/dist/index.d.ts +0 -238
package/README.md
CHANGED
|
@@ -286,7 +286,7 @@ interface FluxionOptions {
|
|
|
286
286
|
nativeWatcher?: boolean;
|
|
287
287
|
injections?: InjectionConfig[];
|
|
288
288
|
moduleDir?: string;
|
|
289
|
-
workerOptions?:
|
|
289
|
+
workerOptions?: WorkerOptions;
|
|
290
290
|
maxRequestBytes?: number;
|
|
291
291
|
logger?: 'one-line' | 'json-line' | InjectionConfig;
|
|
292
292
|
apiExts?: string[];
|
|
@@ -393,24 +393,46 @@ globalThis[Symbol.for('fluxion.injection')]
|
|
|
393
393
|
|
|
394
394
|
### `workerOptions`
|
|
395
395
|
|
|
396
|
-
|
|
396
|
+
Worker pool tuning: how many workers to spawn, and when to proactively recycle one.
|
|
397
397
|
|
|
398
398
|
```ts
|
|
399
399
|
interface WorkerOptions {
|
|
400
|
-
maxWorkerCount
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
400
|
+
maxWorkerCount?: number;
|
|
401
|
+
restartWhen?: Partial<WorkerRestartWhen>;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
interface WorkerRestartWhen {
|
|
405
|
+
/** Recycle when RSS exceeds this many MB. Infinity (default) = disabled. */
|
|
406
|
+
memoryUsageGreaterThan: number;
|
|
407
|
+
/** Recycle when no Ping answer within this many ms. Default 30000. */
|
|
408
|
+
healthzTimeout: number;
|
|
409
|
+
/** Recycle after this many ms of uptime (scheduled rotation). Infinity (default) = disabled. */
|
|
410
|
+
uptimeGreaterThan: number;
|
|
410
411
|
}
|
|
411
412
|
```
|
|
412
413
|
|
|
413
|
-
|
|
414
|
+
- `maxWorkerCount` defaults to `4`, clamped to the CPU count (minimum 1).
|
|
415
|
+
- `restartWhen` lets the primary proactively recycle an unhealthy worker. The worker is hard-killed and immediately respawned when **any** configured condition is met (OR semantics):
|
|
416
|
+
- `memoryUsageGreaterThan` — RSS growth / native leak, caught before the OS OOM-killer. Disabled by default.
|
|
417
|
+
- `healthzTimeout` — a wedged event loop (worker stopped answering Ping: infinite loop, deadlock, GC storm). **Defaults to `30000`ms.**
|
|
418
|
+
- `uptimeGreaterThan` — scheduled rotation to reclaim slow growth / fragmentation. Disabled by default.
|
|
419
|
+
- Conditions are evaluated by the primary against the telemetry it already collects (RSS from stats every ~2s, liveness from Ping every 5s, uptime).
|
|
420
|
+
- A shared **anti-storm guard** bounds recycling: a given slot is restarted at most 3 times per rolling 60s, after which further restarts are suppressed and alerted instead of fork-bombing.
|
|
421
|
+
- Independently of `restartWhen`, **any worker exit — crash, OOM, or proactive recycle — triggers a respawn**, so the pool stays at `maxWorkerCount`.
|
|
422
|
+
|
|
423
|
+
```ts
|
|
424
|
+
fluxion({
|
|
425
|
+
// ...
|
|
426
|
+
workerOptions: {
|
|
427
|
+
maxWorkerCount: 4,
|
|
428
|
+
restartWhen: {
|
|
429
|
+
memoryUsageGreaterThan: 256, // MB; recycle a leaking worker at 256MB RSS
|
|
430
|
+
// healthzTimeout defaults to 30000 — recycle wedged workers after 30s
|
|
431
|
+
// uptimeGreaterThan: 6 * 3600_000, // optionally rotate every 6h
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
});
|
|
435
|
+
```
|
|
414
436
|
|
|
415
437
|
### `https`
|
|
416
438
|
|
|
@@ -525,24 +547,46 @@ globalThis[Symbol.for('fluxion.injection')]
|
|
|
525
547
|
|
|
526
548
|
### `workerOptions`
|
|
527
549
|
|
|
528
|
-
|
|
550
|
+
Worker pool tuning: how many workers to spawn, and when to proactively recycle one.
|
|
529
551
|
|
|
530
552
|
```ts
|
|
531
553
|
interface WorkerOptions {
|
|
532
|
-
maxWorkerCount
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
554
|
+
maxWorkerCount?: number;
|
|
555
|
+
restartWhen?: Partial<WorkerRestartWhen>;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
interface WorkerRestartWhen {
|
|
559
|
+
/** Recycle when RSS exceeds this many MB. Infinity (default) = disabled. */
|
|
560
|
+
memoryUsageGreaterThan: number;
|
|
561
|
+
/** Recycle when no Ping answer within this many ms. Default 30000. */
|
|
562
|
+
healthzTimeout: number;
|
|
563
|
+
/** Recycle after this many ms of uptime (scheduled rotation). Infinity (default) = disabled. */
|
|
564
|
+
uptimeGreaterThan: number;
|
|
542
565
|
}
|
|
543
566
|
```
|
|
544
567
|
|
|
545
|
-
|
|
568
|
+
- `maxWorkerCount` defaults to `4`, clamped to the CPU count (minimum 1).
|
|
569
|
+
- `restartWhen` lets the primary proactively recycle an unhealthy worker. The worker is hard-killed and immediately respawned when **any** configured condition is met (OR semantics):
|
|
570
|
+
- `memoryUsageGreaterThan` — RSS growth / native leak, caught before the OS OOM-killer. Disabled by default.
|
|
571
|
+
- `healthzTimeout` — a wedged event loop (worker stopped answering Ping: infinite loop, deadlock, GC storm). **Defaults to `30000`ms.**
|
|
572
|
+
- `uptimeGreaterThan` — scheduled rotation to reclaim slow growth / fragmentation. Disabled by default.
|
|
573
|
+
- Conditions are evaluated by the primary against the telemetry it already collects (RSS from stats every ~2s, liveness from Ping every 5s, uptime).
|
|
574
|
+
- A shared **anti-storm guard** bounds recycling: a given slot is restarted at most 3 times per rolling 60s, after which further restarts are suppressed and alerted instead of fork-bombing.
|
|
575
|
+
- Independently of `restartWhen`, **any worker exit — crash, OOM, or proactive recycle — triggers a respawn**, so the pool stays at `maxWorkerCount`.
|
|
576
|
+
|
|
577
|
+
```ts
|
|
578
|
+
fluxion({
|
|
579
|
+
// ...
|
|
580
|
+
workerOptions: {
|
|
581
|
+
maxWorkerCount: 4,
|
|
582
|
+
restartWhen: {
|
|
583
|
+
memoryUsageGreaterThan: 256, // MB; recycle a leaking worker at 256MB RSS
|
|
584
|
+
// healthzTimeout defaults to 30000 — recycle wedged workers after 30s
|
|
585
|
+
// uptimeGreaterThan: 6 * 3600_000, // optionally rotate every 6h
|
|
586
|
+
},
|
|
587
|
+
},
|
|
588
|
+
});
|
|
589
|
+
```
|
|
546
590
|
|
|
547
591
|
## Build and Test
|
|
548
592
|
|