@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.
@@ -16,6 +16,24 @@ const getAuditPrefix = () => {
16
16
  let redisClient = null;
17
17
  let retentionPolicy = null;
18
18
  let cleanupInterval = null;
19
+ const REDIS_SHUTDOWN_TIMEOUT_MS = 100;
20
+ const closeRedisClient = async (client) => {
21
+ try {
22
+ await Promise.race([
23
+ client.quit(),
24
+ new Promise((_, reject) => {
25
+ const timeoutId = globalThis.setTimeout(() => {
26
+ reject(new Error('DeadLetterQueue Redis shutdown timed out'));
27
+ }, REDIS_SHUTDOWN_TIMEOUT_MS);
28
+ timeoutId.unref?.();
29
+ }),
30
+ ]);
31
+ }
32
+ catch (error) {
33
+ Logger.warn('DeadLetterQueue graceful Redis shutdown failed, forcing disconnect', error);
34
+ client.disconnect();
35
+ }
36
+ };
19
37
  /**
20
38
  * Helper: Get DLQ key
21
39
  */
@@ -536,7 +554,7 @@ export const DeadLetterQueue = Object.freeze({
536
554
  cleanupInterval = null;
537
555
  }
538
556
  if (redisClient) {
539
- await redisClient.quit();
557
+ await closeRedisClient(redisClient);
540
558
  redisClient = null;
541
559
  }
542
560
  retentionPolicy = null;
@@ -3,7 +3,7 @@
3
3
  * Enable workers to process multiple queues with different priorities
4
4
  * Sealed namespace for immutability
5
5
  */
6
- import { ErrorFactory, Logger } from '@zintrust/core';
6
+ import { ErrorFactory, Logger, ShutdownTrace } from '@zintrust/core';
7
7
  import { Worker } from 'bullmq';
8
8
  import { PriorityQueue } from './PriorityQueue.js';
9
9
  // Internal state
@@ -28,6 +28,13 @@ const createQueueWorker = async (workerName, queueConfig, processor) => {
28
28
  });
29
29
  return processor(job);
30
30
  }, workerOptions);
31
+ ShutdownTrace.logBullMQWorker('multi-queue-worker.create', worker, {
32
+ workerName,
33
+ queueName: queueConfig.name,
34
+ configuredConcurrency: queueConfig.concurrency,
35
+ configuredPriority: queueConfig.priority,
36
+ enabled: queueConfig.enabled,
37
+ });
31
38
  // Set up event listeners
32
39
  worker.on('completed', (job) => {
33
40
  const stats = multiQueueWorkers.get(workerName)?.stats.get(queueConfig.name);
@@ -260,7 +267,17 @@ export const MultiQueueWorker = Object.freeze({
260
267
  throw ErrorFactory.createNotFoundError(`Multi-queue worker "${workerName}" not found`);
261
268
  }
262
269
  // Close all workers
263
- const closePromises = Array.from(mqw.workers.values()).map(async (worker) => worker.close());
270
+ const closePromises = Array.from(mqw.workers.entries()).map(async ([queueName, worker]) => {
271
+ ShutdownTrace.logBullMQWorker('multi-queue-worker.remove.close.start', worker, {
272
+ workerName,
273
+ queueName,
274
+ });
275
+ await worker.close(true);
276
+ ShutdownTrace.logBullMQWorker('multi-queue-worker.remove.close.complete', worker, {
277
+ workerName,
278
+ queueName,
279
+ });
280
+ });
264
281
  await Promise.all(closePromises);
265
282
  multiQueueWorkers.delete(workerName);
266
283
  Logger.info(`Multi-queue worker removed: ${workerName}`);
@@ -270,13 +287,27 @@ export const MultiQueueWorker = Object.freeze({
270
287
  */
271
288
  async shutdown() {
272
289
  Logger.info('MultiQueueWorker shutting down...');
290
+ ShutdownTrace.logHandles('multi-queue-worker.shutdown.start', {
291
+ workerGroupCount: multiQueueWorkers.size,
292
+ });
273
293
  const shutdownPromises = Array.from(multiQueueWorkers.values()).map(async (mqw) => {
274
- const closePromises = Array.from(mqw.workers.values()).map(async (worker) => worker.close());
294
+ const closePromises = Array.from(mqw.workers.entries()).map(async ([queueName, worker]) => {
295
+ ShutdownTrace.logBullMQWorker('multi-queue-worker.shutdown.close.start', worker, {
296
+ workerName: mqw.config.workerName,
297
+ queueName,
298
+ });
299
+ await worker.close(true);
300
+ ShutdownTrace.logBullMQWorker('multi-queue-worker.shutdown.close.complete', worker, {
301
+ workerName: mqw.config.workerName,
302
+ queueName,
303
+ });
304
+ });
275
305
  await Promise.all(closePromises);
276
306
  });
277
307
  await Promise.all(shutdownPromises);
278
308
  multiQueueWorkers.clear();
279
309
  Logger.info('MultiQueueWorker shutdown complete');
310
+ ShutdownTrace.logHandles('multi-queue-worker.shutdown.complete');
280
311
  },
281
312
  });
282
313
  // Graceful shutdown handled by WorkerShutdown
@@ -17,7 +17,7 @@ const loadQueueRedisModule = async () => {
17
17
  if (queueRedisModule)
18
18
  return queueRedisModule;
19
19
  try {
20
- queueRedisModule = (await import('@zintrust/queue-redis'));
20
+ queueRedisModule = await import('@zintrust/queue-redis');
21
21
  return queueRedisModule;
22
22
  }
23
23
  catch (error) {
@@ -266,9 +266,15 @@ export const PriorityQueue = Object.freeze({
266
266
  */
267
267
  async shutdown() {
268
268
  Logger.info('PriorityQueue shutting down via BullMQRedisQueue...');
269
+ if (!queueRedisModule) {
270
+ Logger.info('PriorityQueue shutdown complete');
271
+ return;
272
+ }
269
273
  const queueRedis = await loadQueueRedisModule();
270
- if (!queueRedis)
274
+ if (!queueRedis) {
275
+ Logger.info('PriorityQueue shutdown complete');
271
276
  return;
277
+ }
272
278
  await queueRedis.BullMQRedisQueue.shutdown();
273
279
  Logger.info('PriorityQueue shutdown complete');
274
280
  },
@@ -26,6 +26,20 @@ import { resolveWorkerKeyPrefix } from './config/workerConfig.js';
26
26
  import { recordQueueMonitorJob } from './queueMonitorHistory.js';
27
27
  import { DbWorkerStore, InMemoryWorkerStore, RedisWorkerStore, } from './storage/WorkerStore.js';
28
28
  const path = NodeSingletons.path;
29
+ const createNoopShutdownTrace = () => ({
30
+ log: () => undefined,
31
+ logHandles: () => undefined,
32
+ });
33
+ const resolveShutdownTrace = () => {
34
+ try {
35
+ const candidate = ZintrustCoreModule.ShutdownTrace;
36
+ return candidate ?? createNoopShutdownTrace();
37
+ }
38
+ catch {
39
+ return createNoopShutdownTrace();
40
+ }
41
+ };
42
+ const ShutdownTrace = resolveShutdownTrace();
29
43
  const isNodeRuntime = () => typeof process !== 'undefined' && Boolean(process.versions?.node);
30
44
  const resolveProjectRoot = () => {
31
45
  const envRoot = Env.get('ZINTRUST_PROJECT_ROOT', '').trim();
@@ -287,6 +301,64 @@ const workers = new Map();
287
301
  let workerStore = InMemoryWorkerStore.create();
288
302
  let workerStoreConfigured = false;
289
303
  let workerStoreConfig = null;
304
+ const collectWorkerStoresForCleanup = (stores = []) => {
305
+ const storesToClose = new Set(stores);
306
+ if (workerStoreConfigured) {
307
+ storesToClose.add(workerStore);
308
+ }
309
+ for (const store of storeInstanceCache.values()) {
310
+ storesToClose.add(store);
311
+ }
312
+ return storesToClose;
313
+ };
314
+ const closeWorkerStores = async (stores = []) => {
315
+ const storesToClose = collectWorkerStoresForCleanup(stores);
316
+ ShutdownTrace.logHandles('worker-factory.store-cleanup.start', {
317
+ storeCount: storesToClose.size,
318
+ storeTypes: Array.from(storesToClose).map((store) => store.constructor.name),
319
+ });
320
+ await Promise.all(Array.from(storesToClose).map(async (store) => {
321
+ if (typeof store.close !== 'function')
322
+ return;
323
+ await shutdownWithTimeout('WorkerStore', async () => {
324
+ await store.close?.();
325
+ }, 100);
326
+ }));
327
+ workerStoreConfigured = false;
328
+ workerStoreConfig = null;
329
+ workerStore = InMemoryWorkerStore.create();
330
+ storeInstanceCache.clear();
331
+ ShutdownTrace.logHandles('worker-factory.store-cleanup.complete');
332
+ };
333
+ const shutdownWithTimeout = async (label, action, timeoutMs = 150) => {
334
+ let timeoutId;
335
+ try {
336
+ ShutdownTrace.log('worker-factory.step.start', { label, timeoutMs });
337
+ await Promise.race([
338
+ action(),
339
+ new Promise((_, reject) => {
340
+ timeoutId = globalThis.setTimeout(() => {
341
+ reject(ErrorFactory.createGeneralError(`${label} shutdown timed out`, { timeoutMs }));
342
+ }, timeoutMs);
343
+ timeoutId.unref?.();
344
+ }),
345
+ ]);
346
+ ShutdownTrace.logHandles('worker-factory.step.complete', { label, timeoutMs });
347
+ }
348
+ catch (error) {
349
+ Logger.warn(`${label} shutdown failed or timed out`, error);
350
+ ShutdownTrace.logHandles('worker-factory.step.failed', {
351
+ label,
352
+ timeoutMs,
353
+ error: error instanceof Error ? error.message : String(error),
354
+ });
355
+ }
356
+ finally {
357
+ if (timeoutId !== undefined) {
358
+ globalThis.clearTimeout(timeoutId);
359
+ }
360
+ }
361
+ };
290
362
  const processorRegistry = new Map();
291
363
  const processorPathRegistry = new Map();
292
364
  const processorResolvers = [];
@@ -2626,6 +2698,9 @@ export const WorkerFactory = Object.freeze({
2626
2698
  */
2627
2699
  async shutdown() {
2628
2700
  Logger.info('WorkerFactory shutting down...');
2701
+ ShutdownTrace.logHandles('worker-factory.shutdown.start', {
2702
+ workerCount: workers.size,
2703
+ });
2629
2704
  const workerEntries = Array.from(workers.entries());
2630
2705
  const workerNames = workerEntries.map(([name]) => name);
2631
2706
  // Bulk-update persisted statuses before stopping workers to avoid per-worker DB updates
@@ -2659,31 +2734,50 @@ export const WorkerFactory = Object.freeze({
2659
2734
  await Promise.all(workerNames.map(async (name) => WorkerFactory.stop(name, undefined, { skipPersistedUpdate: true })));
2660
2735
  // Shutdown all modules
2661
2736
  ResourceMonitor.stop();
2662
- await WorkerMetrics.shutdown();
2663
- await MultiQueueWorker.shutdown();
2664
- await ComplianceManager.shutdown();
2665
- await PriorityQueue.shutdown();
2666
2737
  HealthMonitor.shutdown();
2667
2738
  AutoScaler.stop();
2668
- ClusterLock.shutdown();
2669
2739
  WorkerVersioning.shutdown();
2670
2740
  CanaryController.shutdown();
2671
2741
  DatacenterOrchestrator.shutdown();
2672
- PluginManager.shutdown();
2673
2742
  Observability.shutdown();
2674
- await DeadLetterQueue.shutdown();
2675
2743
  CircuitBreaker.shutdown();
2744
+ await Promise.all([
2745
+ shutdownWithTimeout('WorkerMetrics', async () => {
2746
+ await WorkerMetrics.shutdown();
2747
+ }),
2748
+ shutdownWithTimeout('MultiQueueWorker', async () => {
2749
+ await MultiQueueWorker.shutdown();
2750
+ }),
2751
+ shutdownWithTimeout('ComplianceManager', async () => {
2752
+ await ComplianceManager.shutdown();
2753
+ }),
2754
+ shutdownWithTimeout('PriorityQueue', async () => {
2755
+ await PriorityQueue.shutdown();
2756
+ }),
2757
+ shutdownWithTimeout('ClusterLock', async () => {
2758
+ await ClusterLock.shutdown();
2759
+ }),
2760
+ shutdownWithTimeout('PluginManager', async () => {
2761
+ await PluginManager.shutdown();
2762
+ }),
2763
+ shutdownWithTimeout('DeadLetterQueue', async () => {
2764
+ await DeadLetterQueue.shutdown();
2765
+ }),
2766
+ closeWorkerStores(storeGroups.keys()),
2767
+ ]);
2768
+ ShutdownTrace.logHandles('worker-factory.shutdown.after-parallel-teardown', {
2769
+ workerCount: workers.size,
2770
+ });
2676
2771
  workers.clear();
2677
2772
  Logger.info('WorkerFactory shutdown complete');
2773
+ ShutdownTrace.logHandles('worker-factory.shutdown.complete');
2678
2774
  },
2679
2775
  /**
2680
2776
  * Reset persistence connection state.
2681
2777
  * Useful when connections become stale in long-running processes or serverless environments.
2682
2778
  */
2683
2779
  async resetPersistence() {
2684
- workerStoreConfigured = false;
2685
- workerStore = InMemoryWorkerStore.create();
2686
- storeInstanceCache.clear();
2780
+ await closeWorkerStores();
2687
2781
  Logger.info('Worker persistence configuration reset');
2688
2782
  },
2689
2783
  });
@@ -0,0 +1,12 @@
1
+ type DurableObjectState = {
2
+ storage: {
3
+ get: (key: string) => Promise<unknown>;
4
+ put: (key: string, value: unknown) => Promise<void>;
5
+ };
6
+ };
7
+ export declare class ZinTrustWorkerShutdownDurableObject {
8
+ private readonly state;
9
+ constructor(state: DurableObjectState);
10
+ fetch(request: Request): Promise<Response>;
11
+ }
12
+ export {};
@@ -0,0 +1,41 @@
1
+ import { Logger } from '@zintrust/core';
2
+ const loadState = async (state) => {
3
+ const stored = (await state.storage.get('shutdown'));
4
+ return stored ?? { shuttingDown: false };
5
+ };
6
+ const saveState = async (state, value) => {
7
+ await state.storage.put('shutdown', value);
8
+ };
9
+ // eslint-disable-next-line no-restricted-syntax
10
+ export class ZinTrustWorkerShutdownDurableObject {
11
+ state;
12
+ constructor(state) {
13
+ this.state = state;
14
+ }
15
+ async fetch(request) {
16
+ const url = new URL(request.url);
17
+ const path = url.pathname;
18
+ if (request.method === 'GET' && path === '/status') {
19
+ const current = await loadState(this.state);
20
+ return new Response(JSON.stringify(current), {
21
+ status: 200,
22
+ headers: { 'content-type': 'application/json' },
23
+ });
24
+ }
25
+ if (request.method === 'POST' && path === '/shutdown') {
26
+ const payload = (await request.json().catch(() => ({})));
27
+ const next = {
28
+ shuttingDown: true,
29
+ startedAt: new Date().toISOString(),
30
+ reason: payload.reason ?? 'manual',
31
+ };
32
+ await saveState(this.state, next);
33
+ Logger.info('Worker shutdown requested via Durable Object', next);
34
+ return new Response(JSON.stringify({ ok: true }), {
35
+ status: 202,
36
+ headers: { 'content-type': 'application/json' },
37
+ });
38
+ }
39
+ return new Response('Not Found', { status: 404 });
40
+ }
41
+ }
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@zintrust/workers",
3
- "version": "1.5.0",
4
- "buildDate": "2026-04-24T13:03:50.257Z",
3
+ "version": "1.7.1",
4
+ "buildDate": "2026-05-01T05:25:37.587Z",
5
5
  "buildEnvironment": {
6
- "node": "v20.20.2",
7
- "platform": "linux",
8
- "arch": "x64"
6
+ "node": "v22.22.1",
7
+ "platform": "darwin",
8
+ "arch": "arm64"
9
9
  },
10
10
  "git": {
11
- "commit": "739aa697",
12
- "branch": "master"
11
+ "commit": "ef4e9bec",
12
+ "branch": "release"
13
13
  },
14
14
  "package": {
15
15
  "engines": {
@@ -106,8 +106,8 @@
106
106
  "sha256": "dd82e7e2c23a2fcaefc0cb87a1a7931594d6a5f76b758f608c77063f5e8533cd"
107
107
  },
108
108
  "DeadLetterQueue.js": {
109
- "size": 19512,
110
- "sha256": "47ad34c16e8e44a7febb849c56d7558f0f5a951a771c7b2e5c73c8db1b718e63"
109
+ "size": 20135,
110
+ "sha256": "7e60e3cef67195cc9dff4f6580d78db1012da4a688719ba193d5f9b984757583"
111
111
  },
112
112
  "HealthMonitor.d.ts": {
113
113
  "size": 1485,
@@ -122,8 +122,8 @@
122
122
  "sha256": "45d2b0a22c187de40aaf8d26ec69b051ae1fc08eff0c200dd93ed03e2406c066"
123
123
  },
124
124
  "MultiQueueWorker.js": {
125
- "size": 10708,
126
- "sha256": "23837171b31c5242e4b43226cb0acae815dea0ce7b1628aa1428a86b24689230"
125
+ "size": 12067,
126
+ "sha256": "e7bf8e95b6ff589548c3aef2c12a644e43d5ca52a6c6430ce0cee0931ad47979"
127
127
  },
128
128
  "NotificationWorker.d.ts": {
129
129
  "size": 952,
@@ -154,8 +154,8 @@
154
154
  "sha256": "c9bca520824e523f0e7d7f0f04be0e36de8375d5b9cc0319238f6d9460186df2"
155
155
  },
156
156
  "PriorityQueue.js": {
157
- "size": 8718,
158
- "sha256": "f8ed5f5dc27ffe0d610eb758a0094bcdc3af39512d1ee824852872eeaf185245"
157
+ "size": 8911,
158
+ "sha256": "94c80b52b28e6e67c7b159796ade26d88248449bb777c1663f50c6c6040c0701"
159
159
  },
160
160
  "ResourceMonitor.d.ts": {
161
161
  "size": 4019,
@@ -178,8 +178,8 @@
178
178
  "sha256": "3869f960c87260588e40941ff91bffcfa0757be7a04815fd28b57dd4840c51df"
179
179
  },
180
180
  "WorkerFactory.js": {
181
- "size": 107617,
182
- "sha256": "c15002aa229ddf992d2b302a8503f00ecddb78ec97d1afa38de6d9685b9c8b2b"
181
+ "size": 111089,
182
+ "sha256": "bf326ae52a4cd75ea806d8d43b6b882ecb2f89dafaf23d8fb25b07f7b04b2a00"
183
183
  },
184
184
  "WorkerInit.d.ts": {
185
185
  "size": 3284,
@@ -213,6 +213,14 @@
213
213
  "size": 7711,
214
214
  "sha256": "e43e163b1524b9cddaf7ec7432ffbb75686d6719881208dee5b1b8f97e997e5a"
215
215
  },
216
+ "WorkerShutdownDurableObject.d.ts": {
217
+ "size": 354,
218
+ "sha256": "521df11172067bc036bc7b95ff6adf40b7c594afa0454742963317ddfe776d37"
219
+ },
220
+ "WorkerShutdownDurableObject.js": {
221
+ "size": 1547,
222
+ "sha256": "9c7298133dfc4073fda80d3fe9a37ac00d31cacf500ce10c1dd43a70c3a8ddd7"
223
+ },
216
224
  "WorkerVersioning.d.ts": {
217
225
  "size": 2881,
218
226
  "sha256": "a3f1f9e518e8a46201b181679bb5d7a484da7c021b4b7cfd5653cf98fe36e995"
@@ -221,6 +229,10 @@
221
229
  "size": 10953,
222
230
  "sha256": "8af20d462270e7044c6ea983821f5b6e6ce8a5caf39b6e8fefff07c9a0bf071e"
223
231
  },
232
+ "build-manifest.json": {
233
+ "size": 20157,
234
+ "sha256": "ea95db4230744891abd40a62aad798215c2f9c104279201aab65fdf8768692fb"
235
+ },
224
236
  "config/workerConfig.d.ts": {
225
237
  "size": 282,
226
238
  "sha256": "4671566a0cba372852c049ba66f7671ec19f5db38b0eaed1815eb532e7d58109"
@@ -403,7 +415,7 @@
403
415
  },
404
416
  "index.js": {
405
417
  "size": 2336,
406
- "sha256": "1ada0549b24bb8919f4fffb436c22a9568114f155743b50d722dae973d2b3ceb"
418
+ "sha256": "3455af7d26baf664eaea828c1ed722444216ff13caf7a9b3cc937acc885955fb"
407
419
  },
408
420
  "queueMonitorHistory.d.ts": {
409
421
  "size": 433,
@@ -540,6 +552,22 @@
540
552
  "ui/types/worker-ui.js": {
541
553
  "size": 94,
542
554
  "sha256": "7e9f752c2a8eb29dab365b0c836bac90fa7d3567aaf961537d3aa782e85c884e"
555
+ },
556
+ "ui/workers/index.html": {
557
+ "size": 7940,
558
+ "sha256": "a71e384de568f720ff23bf5c90dca60cc97d30c0bbb4ccf5c3b026a8086381b4"
559
+ },
560
+ "ui/workers/main.js": {
561
+ "size": 60723,
562
+ "sha256": "8437771f28963e1b039bee0b1721a8e83a8c65bed19dbd89af0e37d5a2882bb4"
563
+ },
564
+ "ui/workers/styles.css": {
565
+ "size": 22652,
566
+ "sha256": "6de91f206251b0b69ca1a41b71b454b00e3b1213a9762abd8fd8f0ff0381556b"
567
+ },
568
+ "ui/workers/zintrust.svg": {
569
+ "size": 1035,
570
+ "sha256": "9b791269aad740b4191b0ae9f005b08bb28a3407a79a8ed38c11d225fa443f69"
543
571
  }
544
572
  }
545
573
  }
@@ -0,0 +1,202 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>ZinTrust Workers Dashboard</title>
7
+ <link rel="stylesheet" href="workers/styles.css" />
8
+ </head>
9
+ <body>
10
+ <div class="container">
11
+ <div class="header">
12
+ <div class="header-top">
13
+ <div style="display: flex; align-items: center; gap: 16px">
14
+ <div class="logo-frame">
15
+ <img src="workers/zintrust.svg" alt="ZinTrust" class="logo-img" />
16
+ </div>
17
+ <h1>ZinTrust Workers</h1>
18
+ </div>
19
+ <div class="header-actions">
20
+ <button id="theme-toggle" class="theme-toggle">
21
+ <svg class="icon" viewBox="0 0 24 24">
22
+ <circle cx="12" cy="12" r="5" />
23
+ <path
24
+ d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"
25
+ />
26
+ </svg>
27
+ Theme
28
+ </button>
29
+ <button id="auto-refresh-toggle" class="btn" onclick="toggleAutoRefresh()">
30
+ <svg id="auto-refresh-icon" class="icon" viewBox="0 0 24 24">
31
+ <polygon points="5 3 19 12 5 21 5 3" />
32
+ </svg>
33
+ <span id="auto-refresh-label">Auto Refresh</span>
34
+ </button>
35
+ <button class="btn" onclick="fetchData()">
36
+ <svg class="icon" viewBox="0 0 24 24">
37
+ <path d="M23 4v6h-6" />
38
+ <path d="M1 20v-6h6" />
39
+ <path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15" />
40
+ </svg>
41
+ Refresh
42
+ </button>
43
+ <button class="btn btn-primary" onclick="showAddWorkerModal()">
44
+ <svg class="icon" viewBox="0 0 24 24">
45
+ <line x1="12" y1="5" x2="12" y2="19" />
46
+ <line x1="5" y1="12" x2="19" y2="12" />
47
+ </svg>
48
+ Add Worker
49
+ </button>
50
+ </div>
51
+ </div>
52
+
53
+ <div class="nav-bar">
54
+ <nav class="nav-links">
55
+ <a href="/queue-monitor" class="nav-link">Queue Monitor</a>
56
+ <a href="/telemetry" class="nav-link">Telemetry</a>
57
+ <a href="/metrics" class="nav-link">Metrics</a>
58
+ </nav>
59
+ </div>
60
+
61
+ <div class="filters-bar">
62
+ <div class="filter-group">
63
+ <span>Status:</span>
64
+ <select id="status-filter">
65
+ <option value="">All Status</option>
66
+ <option value="running">Running</option>
67
+ <option value="stopped">Stopped</option>
68
+ <option value="error">Error</option>
69
+ <option value="paused">Paused</option>
70
+ </select>
71
+ </div>
72
+ <div class="filter-group">
73
+ <span>Driver:</span>
74
+ <select id="driver-filter">
75
+ <option value="">All Drivers</option>
76
+ </select>
77
+ </div>
78
+ <div class="filter-group">
79
+ <span>Sort:</span>
80
+ <select id="sort-select">
81
+ <option value="name">Sort by Name</option>
82
+ <option value="status" selected>Sort by Status</option>
83
+ <option value="driver">Sort by Driver</option>
84
+ <option value="health">Sort by Health</option>
85
+ <option value="version">Sort by Version</option>
86
+ <option value="processed">Sort by Performance</option>
87
+ </select>
88
+ </div>
89
+ <div style="flex-grow: 1"></div>
90
+ <div class="search-box">
91
+ <svg class="search-icon" viewBox="0 0 24 24">
92
+ <circle cx="11" cy="11" r="8"></circle>
93
+ <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
94
+ </svg>
95
+ <input type="text" id="search-input" placeholder="Search workers..." />
96
+ </div>
97
+ </div>
98
+ </div>
99
+
100
+ <div id="loading" style="text-align: center; padding: 40px; color: var(--muted)">
101
+ <div>Loading workers...</div>
102
+ </div>
103
+
104
+ <div
105
+ id="error"
106
+ style="display: none; text-align: center; padding: 40px; color: var(--danger)"
107
+ >
108
+ <div>Failed to load workers data</div>
109
+ <button class="btn" onclick="fetchData()" style="margin-top: 16px">Retry</button>
110
+ </div>
111
+
112
+ <div id="workers-content" style="display: none">
113
+ <div class="summary-bar" id="queue-summary">
114
+ <div class="summary-item">
115
+ <span class="summary-label">Queue Driver</span>
116
+ <span class="summary-value" id="queue-driver">-</span>
117
+ </div>
118
+ <div class="summary-item">
119
+ <span class="summary-label">Queues</span>
120
+ <span class="summary-value" id="queue-total">0</span>
121
+ </div>
122
+ <div class="summary-item">
123
+ <span class="summary-label">Jobs</span>
124
+ <span class="summary-value" id="queue-jobs">0</span>
125
+ </div>
126
+ <div class="summary-item">
127
+ <span class="summary-label">Processing</span>
128
+ <span class="summary-value" id="queue-processing">0</span>
129
+ </div>
130
+ <div class="summary-item">
131
+ <span class="summary-label">Failed</span>
132
+ <span class="summary-value" id="queue-failed">0</span>
133
+ </div>
134
+ <div class="summary-item">
135
+ <span class="summary-label">Drivers</span>
136
+ <div class="drivers-list" id="drivers-list"></div>
137
+ </div>
138
+ </div>
139
+ <div class="table-container">
140
+ <div class="table-wrapper">
141
+ <table>
142
+ <thead>
143
+ <tr>
144
+ <th style="width: 250px">Worker</th>
145
+ <th style="width: 120px">Status</th>
146
+ <th style="width: 120px">Health</th>
147
+ <th style="width: 100px">Driver</th>
148
+ <th style="width: 100px">Version</th>
149
+ <th style="width: 320px">Performance</th>
150
+ <th style="width: 180px">Actions</th>
151
+ </tr>
152
+ </thead>
153
+ <tbody id="workers-tbody">
154
+ <!-- Workers will be populated here -->
155
+ </tbody>
156
+ </table>
157
+ </div>
158
+
159
+ <div class="pagination">
160
+ <div class="pagination-info" id="pagination-info">Showing 0-0 of 0 workers</div>
161
+ <div class="pagination-controls">
162
+ <button class="page-btn" id="prev-btn" onclick="loadPage('prev')" disabled>
163
+ <svg
164
+ viewBox="0 0 24 24"
165
+ fill="none"
166
+ stroke="currentColor"
167
+ stroke-linecap="round"
168
+ stroke-linejoin="round"
169
+ >
170
+ <polyline points="15 18 9 12 15 6"></polyline>
171
+ </svg>
172
+ </button>
173
+ <div id="page-numbers" style="display: flex; gap: 8px"></div>
174
+ <button class="page-btn" id="next-btn" onclick="loadPage('next')" disabled>
175
+ <svg
176
+ viewBox="0 0 24 24"
177
+ fill="none"
178
+ stroke="currentColor"
179
+ stroke-linecap="round"
180
+ stroke-linejoin="round"
181
+ >
182
+ <polyline points="9 18 15 12 9 6"></polyline>
183
+ </svg>
184
+ </button>
185
+
186
+ <div class="page-size-selector">
187
+ <span>Show:</span>
188
+ <select id="limit-select" onchange="changeLimit(this.value)">
189
+ <option value="10">10</option>
190
+ <option value="25">25</option>
191
+ <option value="50">50</option>
192
+ <option value="100">100</option>
193
+ </select>
194
+ </div>
195
+ </div>
196
+ </div>
197
+ </div>
198
+ </div>
199
+ </div>
200
+ <script src="workers/main.js"></script>
201
+ </body>
202
+ </html>