@zintrust/workers 0.1.27
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 +861 -0
- package/dist/AnomalyDetection.d.ts +102 -0
- package/dist/AnomalyDetection.js +321 -0
- package/dist/AutoScaler.d.ts +127 -0
- package/dist/AutoScaler.js +425 -0
- package/dist/BroadcastWorker.d.ts +21 -0
- package/dist/BroadcastWorker.js +24 -0
- package/dist/CanaryController.d.ts +103 -0
- package/dist/CanaryController.js +380 -0
- package/dist/ChaosEngineering.d.ts +79 -0
- package/dist/ChaosEngineering.js +216 -0
- package/dist/CircuitBreaker.d.ts +106 -0
- package/dist/CircuitBreaker.js +374 -0
- package/dist/ClusterLock.d.ts +90 -0
- package/dist/ClusterLock.js +385 -0
- package/dist/ComplianceManager.d.ts +177 -0
- package/dist/ComplianceManager.js +556 -0
- package/dist/DatacenterOrchestrator.d.ts +133 -0
- package/dist/DatacenterOrchestrator.js +404 -0
- package/dist/DeadLetterQueue.d.ts +122 -0
- package/dist/DeadLetterQueue.js +539 -0
- package/dist/HealthMonitor.d.ts +42 -0
- package/dist/HealthMonitor.js +301 -0
- package/dist/MultiQueueWorker.d.ts +89 -0
- package/dist/MultiQueueWorker.js +277 -0
- package/dist/NotificationWorker.d.ts +21 -0
- package/dist/NotificationWorker.js +23 -0
- package/dist/Observability.d.ts +153 -0
- package/dist/Observability.js +530 -0
- package/dist/PluginManager.d.ts +123 -0
- package/dist/PluginManager.js +392 -0
- package/dist/PriorityQueue.d.ts +117 -0
- package/dist/PriorityQueue.js +244 -0
- package/dist/ResourceMonitor.d.ts +164 -0
- package/dist/ResourceMonitor.js +605 -0
- package/dist/SLAMonitor.d.ts +110 -0
- package/dist/SLAMonitor.js +274 -0
- package/dist/WorkerFactory.d.ts +193 -0
- package/dist/WorkerFactory.js +1507 -0
- package/dist/WorkerInit.d.ts +85 -0
- package/dist/WorkerInit.js +223 -0
- package/dist/WorkerMetrics.d.ts +114 -0
- package/dist/WorkerMetrics.js +509 -0
- package/dist/WorkerRegistry.d.ts +145 -0
- package/dist/WorkerRegistry.js +319 -0
- package/dist/WorkerShutdown.d.ts +61 -0
- package/dist/WorkerShutdown.js +159 -0
- package/dist/WorkerVersioning.d.ts +107 -0
- package/dist/WorkerVersioning.js +300 -0
- package/dist/build-manifest.json +462 -0
- package/dist/config/workerConfig.d.ts +3 -0
- package/dist/config/workerConfig.js +19 -0
- package/dist/createQueueWorker.d.ts +23 -0
- package/dist/createQueueWorker.js +113 -0
- package/dist/dashboard/index.d.ts +1 -0
- package/dist/dashboard/index.js +1 -0
- package/dist/dashboard/types.d.ts +117 -0
- package/dist/dashboard/types.js +1 -0
- package/dist/dashboard/workers-api.d.ts +4 -0
- package/dist/dashboard/workers-api.js +638 -0
- package/dist/dashboard/workers-dashboard-ui.d.ts +3 -0
- package/dist/dashboard/workers-dashboard-ui.js +1026 -0
- package/dist/dashboard/workers-dashboard.d.ts +4 -0
- package/dist/dashboard/workers-dashboard.js +904 -0
- package/dist/helper/index.d.ts +5 -0
- package/dist/helper/index.js +10 -0
- package/dist/http/WorkerApiController.d.ts +38 -0
- package/dist/http/WorkerApiController.js +312 -0
- package/dist/http/WorkerController.d.ts +374 -0
- package/dist/http/WorkerController.js +1351 -0
- package/dist/http/middleware/CustomValidation.d.ts +92 -0
- package/dist/http/middleware/CustomValidation.js +270 -0
- package/dist/http/middleware/DatacenterValidator.d.ts +3 -0
- package/dist/http/middleware/DatacenterValidator.js +94 -0
- package/dist/http/middleware/EditWorkerValidation.d.ts +7 -0
- package/dist/http/middleware/EditWorkerValidation.js +55 -0
- package/dist/http/middleware/FeaturesValidator.d.ts +3 -0
- package/dist/http/middleware/FeaturesValidator.js +60 -0
- package/dist/http/middleware/InfrastructureValidator.d.ts +31 -0
- package/dist/http/middleware/InfrastructureValidator.js +226 -0
- package/dist/http/middleware/OptionsValidator.d.ts +3 -0
- package/dist/http/middleware/OptionsValidator.js +112 -0
- package/dist/http/middleware/PayloadSanitizer.d.ts +7 -0
- package/dist/http/middleware/PayloadSanitizer.js +42 -0
- package/dist/http/middleware/ProcessorPathSanitizer.d.ts +3 -0
- package/dist/http/middleware/ProcessorPathSanitizer.js +74 -0
- package/dist/http/middleware/QueueNameSanitizer.d.ts +3 -0
- package/dist/http/middleware/QueueNameSanitizer.js +45 -0
- package/dist/http/middleware/ValidateDriver.d.ts +7 -0
- package/dist/http/middleware/ValidateDriver.js +20 -0
- package/dist/http/middleware/VersionSanitizer.d.ts +3 -0
- package/dist/http/middleware/VersionSanitizer.js +25 -0
- package/dist/http/middleware/WorkerNameSanitizer.d.ts +3 -0
- package/dist/http/middleware/WorkerNameSanitizer.js +46 -0
- package/dist/http/middleware/WorkerValidationChain.d.ts +27 -0
- package/dist/http/middleware/WorkerValidationChain.js +185 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +48 -0
- package/dist/routes/workers.d.ts +12 -0
- package/dist/routes/workers.js +81 -0
- package/dist/storage/WorkerStore.d.ts +45 -0
- package/dist/storage/WorkerStore.js +195 -0
- package/dist/type.d.ts +76 -0
- package/dist/type.js +1 -0
- package/dist/ui/router/ui.d.ts +3 -0
- package/dist/ui/router/ui.js +83 -0
- package/dist/ui/types/worker-ui.d.ts +229 -0
- package/dist/ui/types/worker-ui.js +5 -0
- package/package.json +53 -0
- package/src/AnomalyDetection.ts +434 -0
- package/src/AutoScaler.ts +654 -0
- package/src/BroadcastWorker.ts +34 -0
- package/src/CanaryController.ts +531 -0
- package/src/ChaosEngineering.ts +301 -0
- package/src/CircuitBreaker.ts +495 -0
- package/src/ClusterLock.ts +499 -0
- package/src/ComplianceManager.ts +815 -0
- package/src/DatacenterOrchestrator.ts +561 -0
- package/src/DeadLetterQueue.ts +733 -0
- package/src/HealthMonitor.ts +390 -0
- package/src/MultiQueueWorker.ts +431 -0
- package/src/NotificationWorker.ts +33 -0
- package/src/Observability.ts +696 -0
- package/src/PluginManager.ts +551 -0
- package/src/PriorityQueue.ts +351 -0
- package/src/ResourceMonitor.ts +769 -0
- package/src/SLAMonitor.ts +408 -0
- package/src/WorkerFactory.ts +2108 -0
- package/src/WorkerInit.ts +313 -0
- package/src/WorkerMetrics.ts +709 -0
- package/src/WorkerRegistry.ts +443 -0
- package/src/WorkerShutdown.ts +210 -0
- package/src/WorkerVersioning.ts +422 -0
- package/src/config/workerConfig.ts +25 -0
- package/src/createQueueWorker.ts +174 -0
- package/src/dashboard/index.ts +6 -0
- package/src/dashboard/types.ts +141 -0
- package/src/dashboard/workers-api.ts +785 -0
- package/src/dashboard/zintrust.svg +30 -0
- package/src/helper/index.ts +11 -0
- package/src/http/WorkerApiController.ts +369 -0
- package/src/http/WorkerController.ts +1512 -0
- package/src/http/middleware/CustomValidation.ts +360 -0
- package/src/http/middleware/DatacenterValidator.ts +124 -0
- package/src/http/middleware/EditWorkerValidation.ts +74 -0
- package/src/http/middleware/FeaturesValidator.ts +82 -0
- package/src/http/middleware/InfrastructureValidator.ts +295 -0
- package/src/http/middleware/OptionsValidator.ts +144 -0
- package/src/http/middleware/PayloadSanitizer.ts +52 -0
- package/src/http/middleware/ProcessorPathSanitizer.ts +86 -0
- package/src/http/middleware/QueueNameSanitizer.ts +55 -0
- package/src/http/middleware/ValidateDriver.ts +29 -0
- package/src/http/middleware/VersionSanitizer.ts +30 -0
- package/src/http/middleware/WorkerNameSanitizer.ts +56 -0
- package/src/http/middleware/WorkerValidationChain.ts +230 -0
- package/src/index.ts +98 -0
- package/src/routes/workers.ts +154 -0
- package/src/storage/WorkerStore.ts +240 -0
- package/src/type.ts +89 -0
- package/src/types/queue-monitor.d.ts +38 -0
- package/src/types/queue-redis.d.ts +38 -0
- package/src/ui/README.md +13 -0
- package/src/ui/components/JsonEditor.js +670 -0
- package/src/ui/components/JsonViewer.js +387 -0
- package/src/ui/components/WorkerCard.js +178 -0
- package/src/ui/components/WorkerExpandPanel.js +257 -0
- package/src/ui/components/fetcher.js +42 -0
- package/src/ui/components/sla-scorecard.js +32 -0
- package/src/ui/components/styles.css +30 -0
- package/src/ui/components/table-expander.js +34 -0
- package/src/ui/integration/worker-ui-integration.js +565 -0
- package/src/ui/router/ui.ts +99 -0
- package/src/ui/services/workerApi.js +240 -0
- package/src/ui/types/worker-ui.ts +283 -0
- package/src/ui/utils/jsonValidator.js +444 -0
- package/src/ui/workers/index.html +202 -0
- package/src/ui/workers/main.js +1781 -0
- package/src/ui/workers/styles.css +1350 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Priority Queue Manager
|
|
3
|
+
* BullMQ priority levels with datacenter affinity
|
|
4
|
+
* Sealed namespace for immutability
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ErrorFactory, Logger, type RedisConfig } from '@zintrust/core';
|
|
8
|
+
import { BullMQRedisQueue } from '@zintrust/queue-redis';
|
|
9
|
+
import type { Queue } from 'bullmq';
|
|
10
|
+
|
|
11
|
+
export type PriorityLevel = 'critical' | 'high' | 'normal' | 'low';
|
|
12
|
+
|
|
13
|
+
export type JobPriority = {
|
|
14
|
+
level: PriorityLevel;
|
|
15
|
+
value: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type DatacenterAffinity = {
|
|
19
|
+
preferred: string[];
|
|
20
|
+
fallback: string[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type PriorityJobOptions = {
|
|
24
|
+
priority: PriorityLevel;
|
|
25
|
+
datacenter?: DatacenterAffinity;
|
|
26
|
+
delay?: number;
|
|
27
|
+
attempts?: number;
|
|
28
|
+
backoff?: {
|
|
29
|
+
type: 'exponential' | 'fixed';
|
|
30
|
+
delay: number;
|
|
31
|
+
};
|
|
32
|
+
removeOnComplete?: boolean | number;
|
|
33
|
+
removeOnFail?: boolean | number;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type QueueInfo = {
|
|
37
|
+
name: string;
|
|
38
|
+
isPaused: boolean;
|
|
39
|
+
jobCounts: {
|
|
40
|
+
active: number;
|
|
41
|
+
waiting: number;
|
|
42
|
+
completed: number;
|
|
43
|
+
failed: number;
|
|
44
|
+
delayed: number;
|
|
45
|
+
paused: number;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Priority mappings
|
|
50
|
+
const PRIORITY_VALUES: Record<PriorityLevel, number> = {
|
|
51
|
+
critical: 10,
|
|
52
|
+
high: 5,
|
|
53
|
+
normal: 1,
|
|
54
|
+
low: 0,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Helper: Get or create queue via shared driver
|
|
59
|
+
*/
|
|
60
|
+
const getQueue = (queueName: string): Queue => {
|
|
61
|
+
return BullMQRedisQueue.getQueue(queueName) as Queue;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Helper: Build job options with priority
|
|
66
|
+
*/
|
|
67
|
+
const buildJobOptions = (options: PriorityJobOptions): Record<string, unknown> => {
|
|
68
|
+
const jobOptions: Record<string, unknown> = {
|
|
69
|
+
priority: PRIORITY_VALUES[options.priority],
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
if (options.delay !== undefined) {
|
|
73
|
+
jobOptions['delay'] = options.delay;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (options.attempts !== undefined) {
|
|
77
|
+
jobOptions['attempts'] = options.attempts;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (options.backoff) {
|
|
81
|
+
jobOptions['backoff'] = options.backoff;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (options.removeOnComplete !== undefined) {
|
|
85
|
+
jobOptions['removeOnComplete'] = options.removeOnComplete;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (options.removeOnFail !== undefined) {
|
|
89
|
+
jobOptions['removeOnFail'] = options.removeOnFail;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Store datacenter affinity in job data (workers can read this)
|
|
93
|
+
if (options.datacenter) {
|
|
94
|
+
jobOptions['datacenter'] = options.datacenter;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return jobOptions;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Helper: Match datacenter affinity
|
|
102
|
+
*/
|
|
103
|
+
const matchesDatacenterAffinity = (
|
|
104
|
+
jobDatacenter: DatacenterAffinity | undefined,
|
|
105
|
+
workerRegion: string
|
|
106
|
+
): boolean => {
|
|
107
|
+
if (!jobDatacenter) {
|
|
108
|
+
return true; // No affinity, can be processed anywhere
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Check preferred datacenters first
|
|
112
|
+
if (jobDatacenter.preferred.includes(workerRegion)) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Check fallback datacenters
|
|
117
|
+
if (jobDatacenter.fallback.includes(workerRegion)) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return false;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Priority Queue Manager - Sealed namespace
|
|
126
|
+
*/
|
|
127
|
+
export const PriorityQueue = Object.freeze({
|
|
128
|
+
/**
|
|
129
|
+
* Initialize with Redis configuration
|
|
130
|
+
*/
|
|
131
|
+
initialize(_config: RedisConfig): void {
|
|
132
|
+
Logger.debug('PriorityQueue.initialize() called - auto-initialized via BullMQRedisQueue');
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Add a job to the queue with priority
|
|
137
|
+
*/
|
|
138
|
+
async addJob<T = unknown>(
|
|
139
|
+
queueName: string,
|
|
140
|
+
jobName: string,
|
|
141
|
+
data: T,
|
|
142
|
+
options: PriorityJobOptions
|
|
143
|
+
): Promise<string> {
|
|
144
|
+
const queue = getQueue(queueName);
|
|
145
|
+
const jobOptions = buildJobOptions(options);
|
|
146
|
+
|
|
147
|
+
try {
|
|
148
|
+
const job = await queue.add(jobName, data, jobOptions);
|
|
149
|
+
|
|
150
|
+
Logger.debug(`Added job "${jobName}" to queue "${queueName}"`, {
|
|
151
|
+
jobId: job.id,
|
|
152
|
+
priority: options.priority,
|
|
153
|
+
datacenter: options.datacenter,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
if (job.id === undefined) {
|
|
157
|
+
throw ErrorFactory.createWorkerError(
|
|
158
|
+
`Failed to add job "${jobName}" to queue "${queueName}": missing job id`
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return job.id;
|
|
163
|
+
} catch (error) {
|
|
164
|
+
Logger.error(`Failed to add job "${jobName}" to queue "${queueName}"`, error);
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Add multiple jobs in bulk
|
|
171
|
+
*/
|
|
172
|
+
async addBulk<T = unknown>(
|
|
173
|
+
queueName: string,
|
|
174
|
+
jobs: Array<{
|
|
175
|
+
name: string;
|
|
176
|
+
data: T;
|
|
177
|
+
options: PriorityJobOptions;
|
|
178
|
+
}>
|
|
179
|
+
): Promise<string[]> {
|
|
180
|
+
const queue = getQueue(queueName);
|
|
181
|
+
|
|
182
|
+
try {
|
|
183
|
+
const bulkJobs = jobs.map((job) => ({
|
|
184
|
+
name: job.name,
|
|
185
|
+
data: job.data,
|
|
186
|
+
opts: buildJobOptions(job.options),
|
|
187
|
+
}));
|
|
188
|
+
|
|
189
|
+
const addedJobs = await queue.addBulk(bulkJobs);
|
|
190
|
+
|
|
191
|
+
Logger.info(`Added ${addedJobs.length} jobs to queue "${queueName}"`);
|
|
192
|
+
|
|
193
|
+
return addedJobs.map((job) => {
|
|
194
|
+
if (job.id === undefined) {
|
|
195
|
+
throw ErrorFactory.createWorkerError(
|
|
196
|
+
`Failed to add job to queue "${queueName}": missing job id`
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
return job.id;
|
|
200
|
+
});
|
|
201
|
+
} catch (error) {
|
|
202
|
+
Logger.error(`Failed to add bulk jobs to queue "${queueName}"`, error);
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Get job by ID
|
|
209
|
+
*/
|
|
210
|
+
async getJob(queueName: string, jobId: string) {
|
|
211
|
+
const queue = getQueue(queueName);
|
|
212
|
+
return queue.getJob(jobId);
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Remove a job
|
|
217
|
+
*/
|
|
218
|
+
async removeJob(queueName: string, jobId: string): Promise<void> {
|
|
219
|
+
const queue = getQueue(queueName);
|
|
220
|
+
const job = await queue.getJob(jobId);
|
|
221
|
+
|
|
222
|
+
if (job) {
|
|
223
|
+
await job.remove();
|
|
224
|
+
Logger.debug(`Removed job ${jobId} from queue "${queueName}"`);
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Pause a queue
|
|
230
|
+
*/
|
|
231
|
+
async pause(queueName: string): Promise<void> {
|
|
232
|
+
const queue = getQueue(queueName);
|
|
233
|
+
await queue.pause();
|
|
234
|
+
Logger.info(`Paused queue "${queueName}"`);
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Resume a queue
|
|
239
|
+
*/
|
|
240
|
+
async resume(queueName: string): Promise<void> {
|
|
241
|
+
const queue = getQueue(queueName);
|
|
242
|
+
await queue.resume();
|
|
243
|
+
Logger.info(`Resumed queue "${queueName}"`);
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Get queue information
|
|
248
|
+
*/
|
|
249
|
+
async getQueueInfo(queueName: string): Promise<QueueInfo> {
|
|
250
|
+
const queue = getQueue(queueName);
|
|
251
|
+
const isPaused = await queue.isPaused();
|
|
252
|
+
const jobCounts = await queue.getJobCounts();
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
name: queueName,
|
|
256
|
+
isPaused,
|
|
257
|
+
jobCounts: {
|
|
258
|
+
active: jobCounts['active'] || 0,
|
|
259
|
+
waiting: jobCounts['waiting'] || 0,
|
|
260
|
+
completed: jobCounts['completed'] || 0,
|
|
261
|
+
failed: jobCounts['failed'] || 0,
|
|
262
|
+
delayed: jobCounts['delayed'] || 0,
|
|
263
|
+
paused: jobCounts['paused'] || 0,
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Get all queue names
|
|
270
|
+
*/
|
|
271
|
+
getQueueNames(): string[] {
|
|
272
|
+
return BullMQRedisQueue.getQueueNames();
|
|
273
|
+
},
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Drain queue (remove all jobs)
|
|
277
|
+
*/
|
|
278
|
+
async drain(queueName: string, delayed = false): Promise<void> {
|
|
279
|
+
const queue = getQueue(queueName);
|
|
280
|
+
await queue.drain(delayed);
|
|
281
|
+
Logger.info(`Drained queue "${queueName}"`, { delayed });
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Clean old jobs from queue
|
|
286
|
+
*/
|
|
287
|
+
async clean(
|
|
288
|
+
queueName: string,
|
|
289
|
+
grace: number,
|
|
290
|
+
limit: number,
|
|
291
|
+
type: 'completed' | 'failed' | 'delayed' | 'wait' | 'active' | 'paused' = 'completed'
|
|
292
|
+
): Promise<string[]> {
|
|
293
|
+
const queue = getQueue(queueName);
|
|
294
|
+
const jobs = await queue.clean(grace, limit, type);
|
|
295
|
+
|
|
296
|
+
Logger.info(`Cleaned ${jobs.length} ${type} jobs from queue "${queueName}"`);
|
|
297
|
+
|
|
298
|
+
return jobs;
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Obliterate queue (remove all data including queue itself)
|
|
303
|
+
*/
|
|
304
|
+
async obliterate(queueName: string, force = false): Promise<void> {
|
|
305
|
+
const queue = getQueue(queueName);
|
|
306
|
+
await queue.obliterate({ force });
|
|
307
|
+
await BullMQRedisQueue.closeQueue(queueName);
|
|
308
|
+
|
|
309
|
+
Logger.warn(`Obliterated queue "${queueName}"`);
|
|
310
|
+
},
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Get priority value for level
|
|
314
|
+
*/
|
|
315
|
+
getPriorityValue(level: PriorityLevel): number {
|
|
316
|
+
return PRIORITY_VALUES[level];
|
|
317
|
+
},
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Check if job matches datacenter affinity
|
|
321
|
+
*/
|
|
322
|
+
matchesDatacenter(jobDatacenter: DatacenterAffinity | undefined, workerRegion: string): boolean {
|
|
323
|
+
return matchesDatacenterAffinity(jobDatacenter, workerRegion);
|
|
324
|
+
},
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Get queue instance (internal use)
|
|
328
|
+
*/
|
|
329
|
+
getQueueInstance(queueName: string): Queue {
|
|
330
|
+
return getQueue(queueName);
|
|
331
|
+
},
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Close a queue
|
|
335
|
+
*/
|
|
336
|
+
async closeQueue(queueName: string): Promise<void> {
|
|
337
|
+
await BullMQRedisQueue.closeQueue(queueName);
|
|
338
|
+
Logger.info(`Closed queue "${queueName}"`);
|
|
339
|
+
},
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Shutdown and close all queues
|
|
343
|
+
*/
|
|
344
|
+
async shutdown(): Promise<void> {
|
|
345
|
+
Logger.info('PriorityQueue shutting down via BullMQRedisQueue...');
|
|
346
|
+
await BullMQRedisQueue.shutdown();
|
|
347
|
+
Logger.info('PriorityQueue shutdown complete');
|
|
348
|
+
},
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
// Graceful shutdown handled by WorkerShutdown
|