@zintrust/workers 1.5.0 → 1.7.1
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/dist/DeadLetterQueue.js +19 -1
- package/dist/MultiQueueWorker.js +34 -3
- package/dist/PriorityQueue.js +8 -2
- package/dist/WorkerFactory.js +104 -10
- package/dist/WorkerShutdownDurableObject.d.ts +12 -0
- package/dist/WorkerShutdownDurableObject.js +41 -0
- package/dist/build-manifest.json +44 -16
- package/dist/ui/workers/index.html +202 -0
- package/dist/ui/workers/main.js +1952 -0
- package/dist/ui/workers/styles.css +1350 -0
- package/dist/ui/workers/zintrust.svg +30 -0
- package/package.json +2 -2
- package/src/DeadLetterQueue.ts +26 -8
- package/src/MultiQueueWorker.ts +35 -3
- package/src/PriorityQueue.ts +12 -3
- package/src/WorkerFactory.ts +131 -10
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<svg width="120" height="120" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="zt-g2d" x1="10" y1="50" x2="90" y2="50" gradientUnits="userSpaceOnUse">
|
|
4
|
+
<stop stop-color="#22c55e" />
|
|
5
|
+
<stop offset="1" stop-color="#38bdf8" />
|
|
6
|
+
</linearGradient>
|
|
7
|
+
</defs>
|
|
8
|
+
<circle cx="50" cy="50" r="34" stroke="rgba(255,255,255,0.16)" stroke-width="4" />
|
|
9
|
+
<ellipse cx="50" cy="50" rx="40" ry="18" stroke="url(#zt-g2d)" stroke-width="4" />
|
|
10
|
+
<ellipse cx="50" cy="50" rx="18" ry="40" stroke="url(#zt-g2d)" stroke-width="4" opacity="0.75" />
|
|
11
|
+
<circle cx="50" cy="50" r="6" fill="url(#zt-g2d)" />
|
|
12
|
+
<path
|
|
13
|
+
d="M40 52C35 52 32 49 32 44C32 39 35 36 40 36H48"
|
|
14
|
+
stroke="white"
|
|
15
|
+
stroke-width="6"
|
|
16
|
+
stroke-linecap="round"
|
|
17
|
+
/>
|
|
18
|
+
<path
|
|
19
|
+
d="M60 48C65 48 68 51 68 56C68 61 65 64 60 64H52"
|
|
20
|
+
stroke="white"
|
|
21
|
+
stroke-width="6"
|
|
22
|
+
stroke-linecap="round"
|
|
23
|
+
/>
|
|
24
|
+
<path
|
|
25
|
+
d="M44 50H56"
|
|
26
|
+
stroke="rgba(255,255,255,0.22)"
|
|
27
|
+
stroke-width="6"
|
|
28
|
+
stroke-linecap="round"
|
|
29
|
+
/>
|
|
30
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/workers",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Worker orchestration and background job management for ZinTrust.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"node": ">=20.0.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@zintrust/core": "
|
|
43
|
+
"@zintrust/core": "*",
|
|
44
44
|
"@zintrust/queue-monitor": "*",
|
|
45
45
|
"@zintrust/queue-redis": "*"
|
|
46
46
|
},
|
package/src/DeadLetterQueue.ts
CHANGED
|
@@ -85,6 +85,24 @@ const getAuditPrefix = (): string => {
|
|
|
85
85
|
let redisClient: RedisConnection | null = null;
|
|
86
86
|
let retentionPolicy: RetentionPolicy | null = null;
|
|
87
87
|
let cleanupInterval: NodeJS.Timeout | null = null;
|
|
88
|
+
const REDIS_SHUTDOWN_TIMEOUT_MS = 100;
|
|
89
|
+
|
|
90
|
+
const closeRedisClient = async (client: RedisConnection): Promise<void> => {
|
|
91
|
+
try {
|
|
92
|
+
await Promise.race([
|
|
93
|
+
client.quit(),
|
|
94
|
+
new Promise<never>((_, reject) => {
|
|
95
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
96
|
+
reject(new Error('DeadLetterQueue Redis shutdown timed out'));
|
|
97
|
+
}, REDIS_SHUTDOWN_TIMEOUT_MS);
|
|
98
|
+
(timeoutId as { unref?: () => void }).unref?.();
|
|
99
|
+
}),
|
|
100
|
+
]);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
Logger.warn('DeadLetterQueue graceful Redis shutdown failed, forcing disconnect', error);
|
|
103
|
+
client.disconnect();
|
|
104
|
+
}
|
|
105
|
+
};
|
|
88
106
|
|
|
89
107
|
/**
|
|
90
108
|
* Helper: Get DLQ key
|
|
@@ -195,11 +213,11 @@ const cleanupOldEntries = async (): Promise<number> => {
|
|
|
195
213
|
const keys = await client.keys(pattern);
|
|
196
214
|
|
|
197
215
|
const cleanedCounts = await Promise.all(
|
|
198
|
-
|
|
216
|
+
keys.map(async (key: string) => {
|
|
199
217
|
const oldEntries = await client.zrangebyscore(key, '-inf', cutoffTimestamp);
|
|
200
218
|
|
|
201
219
|
await Promise.all(
|
|
202
|
-
|
|
220
|
+
oldEntries.map(async (entryJson: string) => {
|
|
203
221
|
const entry = JSON.parse(entryJson) as FailedJobEntry;
|
|
204
222
|
|
|
205
223
|
if (policy.anonymizeInsteadOfDelete) {
|
|
@@ -345,7 +363,7 @@ export const DeadLetterQueue = Object.freeze({
|
|
|
345
363
|
const key = getDLQKey(queueName);
|
|
346
364
|
const entries = await redisClient.zrange(key, 0, -1);
|
|
347
365
|
|
|
348
|
-
const entry =
|
|
366
|
+
const entry = entries
|
|
349
367
|
.map((e: string) => JSON.parse(e) as FailedJobEntry)
|
|
350
368
|
.find((e: FailedJobEntry) => e.id === jobId);
|
|
351
369
|
|
|
@@ -392,7 +410,7 @@ export const DeadLetterQueue = Object.freeze({
|
|
|
392
410
|
// Get most recent failures first (highest scores)
|
|
393
411
|
const entries = await redisClient.zrevrange(key, 0, limit - 1);
|
|
394
412
|
|
|
395
|
-
return
|
|
413
|
+
return entries.map((e: string) => JSON.parse(e) as FailedJobEntry);
|
|
396
414
|
} catch (error) {
|
|
397
415
|
Logger.error(`Failed to get DLQ entries for queue: ${queueName}`, error);
|
|
398
416
|
return [];
|
|
@@ -579,7 +597,7 @@ export const DeadLetterQueue = Object.freeze({
|
|
|
579
597
|
const auditKey = getAuditKey(failedJobId);
|
|
580
598
|
const entries = await redisClient.zrevrange(auditKey, 0, limit - 1);
|
|
581
599
|
|
|
582
|
-
return
|
|
600
|
+
return entries.map((e: string) => JSON.parse(e) as ComplianceAuditEntry);
|
|
583
601
|
} catch (error) {
|
|
584
602
|
Logger.error(`Failed to get audit log for: ${failedJobId}`, error);
|
|
585
603
|
return [];
|
|
@@ -600,13 +618,13 @@ export const DeadLetterQueue = Object.freeze({
|
|
|
600
618
|
const keys = await client.keys(pattern);
|
|
601
619
|
|
|
602
620
|
const entriesByQueue = await Promise.all(
|
|
603
|
-
|
|
621
|
+
keys.map(async (key: string) => {
|
|
604
622
|
const queueName = key.replace(getDLQPrefix(), '');
|
|
605
623
|
const entries = await client.zrange(key, 0, -1);
|
|
606
624
|
return {
|
|
607
625
|
queueName,
|
|
608
626
|
count: entries.length,
|
|
609
|
-
entries:
|
|
627
|
+
entries: entries.map((e: string) => JSON.parse(e) as FailedJobEntry),
|
|
610
628
|
};
|
|
611
629
|
})
|
|
612
630
|
);
|
|
@@ -729,7 +747,7 @@ export const DeadLetterQueue = Object.freeze({
|
|
|
729
747
|
}
|
|
730
748
|
|
|
731
749
|
if (redisClient) {
|
|
732
|
-
await redisClient
|
|
750
|
+
await closeRedisClient(redisClient);
|
|
733
751
|
redisClient = null;
|
|
734
752
|
}
|
|
735
753
|
|
package/src/MultiQueueWorker.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Sealed namespace for immutability
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { ErrorFactory, Logger } from '@zintrust/core';
|
|
7
|
+
import { ErrorFactory, Logger, ShutdownTrace } from '@zintrust/core';
|
|
8
8
|
import { Worker, type Job, type WorkerOptions } from 'bullmq';
|
|
9
9
|
import { PriorityQueue } from './PriorityQueue';
|
|
10
10
|
|
|
@@ -79,6 +79,14 @@ const createQueueWorker = async (
|
|
|
79
79
|
workerOptions
|
|
80
80
|
);
|
|
81
81
|
|
|
82
|
+
ShutdownTrace.logBullMQWorker('multi-queue-worker.create', worker, {
|
|
83
|
+
workerName,
|
|
84
|
+
queueName: queueConfig.name,
|
|
85
|
+
configuredConcurrency: queueConfig.concurrency,
|
|
86
|
+
configuredPriority: queueConfig.priority,
|
|
87
|
+
enabled: queueConfig.enabled,
|
|
88
|
+
});
|
|
89
|
+
|
|
82
90
|
// Set up event listeners
|
|
83
91
|
worker.on('completed', (job: Job) => {
|
|
84
92
|
const stats = multiQueueWorkers.get(workerName)?.stats.get(queueConfig.name);
|
|
@@ -407,7 +415,17 @@ export const MultiQueueWorker = Object.freeze({
|
|
|
407
415
|
}
|
|
408
416
|
|
|
409
417
|
// Close all workers
|
|
410
|
-
const closePromises = Array.from(mqw.workers.
|
|
418
|
+
const closePromises = Array.from(mqw.workers.entries()).map(async ([queueName, worker]) => {
|
|
419
|
+
ShutdownTrace.logBullMQWorker('multi-queue-worker.remove.close.start', worker, {
|
|
420
|
+
workerName,
|
|
421
|
+
queueName,
|
|
422
|
+
});
|
|
423
|
+
await worker.close(true);
|
|
424
|
+
ShutdownTrace.logBullMQWorker('multi-queue-worker.remove.close.complete', worker, {
|
|
425
|
+
workerName,
|
|
426
|
+
queueName,
|
|
427
|
+
});
|
|
428
|
+
});
|
|
411
429
|
|
|
412
430
|
await Promise.all(closePromises);
|
|
413
431
|
|
|
@@ -421,9 +439,22 @@ export const MultiQueueWorker = Object.freeze({
|
|
|
421
439
|
*/
|
|
422
440
|
async shutdown(): Promise<void> {
|
|
423
441
|
Logger.info('MultiQueueWorker shutting down...');
|
|
442
|
+
ShutdownTrace.logHandles('multi-queue-worker.shutdown.start', {
|
|
443
|
+
workerGroupCount: multiQueueWorkers.size,
|
|
444
|
+
});
|
|
424
445
|
|
|
425
446
|
const shutdownPromises = Array.from(multiQueueWorkers.values()).map(async (mqw) => {
|
|
426
|
-
const closePromises = Array.from(mqw.workers.
|
|
447
|
+
const closePromises = Array.from(mqw.workers.entries()).map(async ([queueName, worker]) => {
|
|
448
|
+
ShutdownTrace.logBullMQWorker('multi-queue-worker.shutdown.close.start', worker, {
|
|
449
|
+
workerName: mqw.config.workerName,
|
|
450
|
+
queueName,
|
|
451
|
+
});
|
|
452
|
+
await worker.close(true);
|
|
453
|
+
ShutdownTrace.logBullMQWorker('multi-queue-worker.shutdown.close.complete', worker, {
|
|
454
|
+
workerName: mqw.config.workerName,
|
|
455
|
+
queueName,
|
|
456
|
+
});
|
|
457
|
+
});
|
|
427
458
|
await Promise.all(closePromises);
|
|
428
459
|
});
|
|
429
460
|
|
|
@@ -432,6 +463,7 @@ export const MultiQueueWorker = Object.freeze({
|
|
|
432
463
|
multiQueueWorkers.clear();
|
|
433
464
|
|
|
434
465
|
Logger.info('MultiQueueWorker shutdown complete');
|
|
466
|
+
ShutdownTrace.logHandles('multi-queue-worker.shutdown.complete');
|
|
435
467
|
},
|
|
436
468
|
});
|
|
437
469
|
|
package/src/PriorityQueue.ts
CHANGED
|
@@ -62,7 +62,7 @@ const loadQueueRedisModule = async (): Promise<QueueRedisModule | undefined> =>
|
|
|
62
62
|
if (queueRedisModule) return queueRedisModule;
|
|
63
63
|
|
|
64
64
|
try {
|
|
65
|
-
queueRedisModule =
|
|
65
|
+
queueRedisModule = await import('@zintrust/queue-redis');
|
|
66
66
|
return queueRedisModule;
|
|
67
67
|
} catch (error) {
|
|
68
68
|
if (!hasWarnedMissingQueueRedis) {
|
|
@@ -86,7 +86,7 @@ const getQueue = async (queueName: string): Promise<Queue> => {
|
|
|
86
86
|
'Optional package "@zintrust/queue-redis" is required for PriorityQueue. Install it to use queue features.'
|
|
87
87
|
);
|
|
88
88
|
}
|
|
89
|
-
return queueRedis.BullMQRedisQueue.getQueue(queueName) as Queue;
|
|
89
|
+
return queueRedis.BullMQRedisQueue.getQueue(queueName) as unknown as Queue;
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
/**
|
|
@@ -378,8 +378,17 @@ export const PriorityQueue = Object.freeze({
|
|
|
378
378
|
*/
|
|
379
379
|
async shutdown(): Promise<void> {
|
|
380
380
|
Logger.info('PriorityQueue shutting down via BullMQRedisQueue...');
|
|
381
|
+
if (!queueRedisModule) {
|
|
382
|
+
Logger.info('PriorityQueue shutdown complete');
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
|
|
381
386
|
const queueRedis = await loadQueueRedisModule();
|
|
382
|
-
if (!queueRedis)
|
|
387
|
+
if (!queueRedis) {
|
|
388
|
+
Logger.info('PriorityQueue shutdown complete');
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
|
|
383
392
|
await queueRedis.BullMQRedisQueue.shutdown();
|
|
384
393
|
Logger.info('PriorityQueue shutdown complete');
|
|
385
394
|
},
|
package/src/WorkerFactory.ts
CHANGED
|
@@ -58,6 +58,27 @@ import {
|
|
|
58
58
|
|
|
59
59
|
const path = NodeSingletons.path;
|
|
60
60
|
|
|
61
|
+
type ShutdownTraceApi = {
|
|
62
|
+
log: (label: string, details?: Record<string, unknown>) => void;
|
|
63
|
+
logHandles: (label: string, details?: Record<string, unknown>) => void;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const createNoopShutdownTrace = (): ShutdownTraceApi => ({
|
|
67
|
+
log: (): void => undefined,
|
|
68
|
+
logHandles: (): void => undefined,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const resolveShutdownTrace = (): ShutdownTraceApi => {
|
|
72
|
+
try {
|
|
73
|
+
const candidate = (ZintrustCoreModule as { ShutdownTrace?: ShutdownTraceApi }).ShutdownTrace;
|
|
74
|
+
return candidate ?? createNoopShutdownTrace();
|
|
75
|
+
} catch {
|
|
76
|
+
return createNoopShutdownTrace();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const ShutdownTrace = resolveShutdownTrace();
|
|
81
|
+
|
|
61
82
|
type ProcessorPackageBridgeGlobal = typeof globalThis & {
|
|
62
83
|
__zintrustProcessorPackageBridges__?: Map<string, Record<string, unknown>>;
|
|
63
84
|
};
|
|
@@ -451,6 +472,82 @@ let workerStore: WorkerStore = InMemoryWorkerStore.create();
|
|
|
451
472
|
let workerStoreConfigured = false;
|
|
452
473
|
let workerStoreConfig: WorkerPersistenceConfig | null = null;
|
|
453
474
|
|
|
475
|
+
const collectWorkerStoresForCleanup = (stores: Iterable<WorkerStore> = []): Set<WorkerStore> => {
|
|
476
|
+
const storesToClose = new Set<WorkerStore>(stores);
|
|
477
|
+
|
|
478
|
+
if (workerStoreConfigured) {
|
|
479
|
+
storesToClose.add(workerStore);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
for (const store of storeInstanceCache.values()) {
|
|
483
|
+
storesToClose.add(store);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
return storesToClose;
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
const closeWorkerStores = async (stores: Iterable<WorkerStore> = []): Promise<void> => {
|
|
490
|
+
const storesToClose = collectWorkerStoresForCleanup(stores);
|
|
491
|
+
|
|
492
|
+
ShutdownTrace.logHandles('worker-factory.store-cleanup.start', {
|
|
493
|
+
storeCount: storesToClose.size,
|
|
494
|
+
storeTypes: Array.from(storesToClose).map((store) => store.constructor.name),
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
await Promise.all(
|
|
498
|
+
Array.from(storesToClose).map(async (store) => {
|
|
499
|
+
if (typeof store.close !== 'function') return;
|
|
500
|
+
|
|
501
|
+
await shutdownWithTimeout(
|
|
502
|
+
'WorkerStore',
|
|
503
|
+
async () => {
|
|
504
|
+
await store.close?.();
|
|
505
|
+
},
|
|
506
|
+
100
|
|
507
|
+
);
|
|
508
|
+
})
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
workerStoreConfigured = false;
|
|
512
|
+
workerStoreConfig = null;
|
|
513
|
+
workerStore = InMemoryWorkerStore.create();
|
|
514
|
+
storeInstanceCache.clear();
|
|
515
|
+
ShutdownTrace.logHandles('worker-factory.store-cleanup.complete');
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
const shutdownWithTimeout = async (
|
|
519
|
+
label: string,
|
|
520
|
+
action: () => Promise<void>,
|
|
521
|
+
timeoutMs = 150
|
|
522
|
+
): Promise<void> => {
|
|
523
|
+
let timeoutId: ReturnType<typeof setTimeout> | undefined;
|
|
524
|
+
|
|
525
|
+
try {
|
|
526
|
+
ShutdownTrace.log('worker-factory.step.start', { label, timeoutMs });
|
|
527
|
+
await Promise.race([
|
|
528
|
+
action(),
|
|
529
|
+
new Promise<never>((_, reject) => {
|
|
530
|
+
timeoutId = globalThis.setTimeout(() => {
|
|
531
|
+
reject(ErrorFactory.createGeneralError(`${label} shutdown timed out`, { timeoutMs }));
|
|
532
|
+
}, timeoutMs);
|
|
533
|
+
(timeoutId as { unref?: () => void }).unref?.();
|
|
534
|
+
}),
|
|
535
|
+
]);
|
|
536
|
+
ShutdownTrace.logHandles('worker-factory.step.complete', { label, timeoutMs });
|
|
537
|
+
} catch (error) {
|
|
538
|
+
Logger.warn(`${label} shutdown failed or timed out`, error as Error);
|
|
539
|
+
ShutdownTrace.logHandles('worker-factory.step.failed', {
|
|
540
|
+
label,
|
|
541
|
+
timeoutMs,
|
|
542
|
+
error: error instanceof Error ? error.message : String(error),
|
|
543
|
+
});
|
|
544
|
+
} finally {
|
|
545
|
+
if (timeoutId !== undefined) {
|
|
546
|
+
globalThis.clearTimeout(timeoutId);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
|
|
454
551
|
export type ProcessorResolver = (
|
|
455
552
|
name: string
|
|
456
553
|
) =>
|
|
@@ -3583,6 +3680,9 @@ export const WorkerFactory = Object.freeze({
|
|
|
3583
3680
|
*/
|
|
3584
3681
|
async shutdown(): Promise<void> {
|
|
3585
3682
|
Logger.info('WorkerFactory shutting down...');
|
|
3683
|
+
ShutdownTrace.logHandles('worker-factory.shutdown.start', {
|
|
3684
|
+
workerCount: workers.size,
|
|
3685
|
+
});
|
|
3586
3686
|
|
|
3587
3687
|
const workerEntries = Array.from(workers.entries());
|
|
3588
3688
|
const workerNames = workerEntries.map(([name]) => name);
|
|
@@ -3628,24 +3728,47 @@ export const WorkerFactory = Object.freeze({
|
|
|
3628
3728
|
|
|
3629
3729
|
// Shutdown all modules
|
|
3630
3730
|
ResourceMonitor.stop();
|
|
3631
|
-
await WorkerMetrics.shutdown();
|
|
3632
|
-
await MultiQueueWorker.shutdown();
|
|
3633
|
-
await ComplianceManager.shutdown();
|
|
3634
|
-
await PriorityQueue.shutdown();
|
|
3635
3731
|
HealthMonitor.shutdown();
|
|
3636
3732
|
AutoScaler.stop();
|
|
3637
|
-
ClusterLock.shutdown();
|
|
3638
3733
|
WorkerVersioning.shutdown();
|
|
3639
3734
|
CanaryController.shutdown();
|
|
3640
3735
|
DatacenterOrchestrator.shutdown();
|
|
3641
|
-
PluginManager.shutdown();
|
|
3642
3736
|
Observability.shutdown();
|
|
3643
|
-
await DeadLetterQueue.shutdown();
|
|
3644
3737
|
CircuitBreaker.shutdown();
|
|
3645
3738
|
|
|
3739
|
+
await Promise.all([
|
|
3740
|
+
shutdownWithTimeout('WorkerMetrics', async () => {
|
|
3741
|
+
await WorkerMetrics.shutdown();
|
|
3742
|
+
}),
|
|
3743
|
+
shutdownWithTimeout('MultiQueueWorker', async () => {
|
|
3744
|
+
await MultiQueueWorker.shutdown();
|
|
3745
|
+
}),
|
|
3746
|
+
shutdownWithTimeout('ComplianceManager', async () => {
|
|
3747
|
+
await ComplianceManager.shutdown();
|
|
3748
|
+
}),
|
|
3749
|
+
shutdownWithTimeout('PriorityQueue', async () => {
|
|
3750
|
+
await PriorityQueue.shutdown();
|
|
3751
|
+
}),
|
|
3752
|
+
shutdownWithTimeout('ClusterLock', async () => {
|
|
3753
|
+
await ClusterLock.shutdown();
|
|
3754
|
+
}),
|
|
3755
|
+
shutdownWithTimeout('PluginManager', async () => {
|
|
3756
|
+
await PluginManager.shutdown();
|
|
3757
|
+
}),
|
|
3758
|
+
shutdownWithTimeout('DeadLetterQueue', async () => {
|
|
3759
|
+
await DeadLetterQueue.shutdown();
|
|
3760
|
+
}),
|
|
3761
|
+
closeWorkerStores(storeGroups.keys()),
|
|
3762
|
+
]);
|
|
3763
|
+
|
|
3764
|
+
ShutdownTrace.logHandles('worker-factory.shutdown.after-parallel-teardown', {
|
|
3765
|
+
workerCount: workers.size,
|
|
3766
|
+
});
|
|
3767
|
+
|
|
3646
3768
|
workers.clear();
|
|
3647
3769
|
|
|
3648
3770
|
Logger.info('WorkerFactory shutdown complete');
|
|
3771
|
+
ShutdownTrace.logHandles('worker-factory.shutdown.complete');
|
|
3649
3772
|
},
|
|
3650
3773
|
|
|
3651
3774
|
/**
|
|
@@ -3653,9 +3776,7 @@ export const WorkerFactory = Object.freeze({
|
|
|
3653
3776
|
* Useful when connections become stale in long-running processes or serverless environments.
|
|
3654
3777
|
*/
|
|
3655
3778
|
async resetPersistence(): Promise<void> {
|
|
3656
|
-
|
|
3657
|
-
workerStore = InMemoryWorkerStore.create();
|
|
3658
|
-
storeInstanceCache.clear();
|
|
3779
|
+
await closeWorkerStores();
|
|
3659
3780
|
Logger.info('Worker persistence configuration reset');
|
|
3660
3781
|
},
|
|
3661
3782
|
});
|