@riktajs/queue 0.10.2 → 0.10.3
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/index.cjs +16251 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +946 -0
- package/dist/index.d.ts +945 -21
- package/dist/index.js +16177 -29
- package/dist/index.js.map +1 -1
- package/package.json +13 -6
- package/dist/config/queue.config.d.ts +0 -43
- package/dist/config/queue.config.d.ts.map +0 -1
- package/dist/config/queue.config.js +0 -82
- package/dist/config/queue.config.js.map +0 -1
- package/dist/constants.d.ts +0 -33
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -37
- package/dist/constants.js.map +0 -1
- package/dist/decorators/events.decorator.d.ts +0 -85
- package/dist/decorators/events.decorator.d.ts.map +0 -1
- package/dist/decorators/events.decorator.js +0 -120
- package/dist/decorators/events.decorator.js.map +0 -1
- package/dist/decorators/index.d.ts +0 -8
- package/dist/decorators/index.d.ts.map +0 -1
- package/dist/decorators/index.js +0 -8
- package/dist/decorators/index.js.map +0 -1
- package/dist/decorators/process.decorator.d.ts +0 -41
- package/dist/decorators/process.decorator.d.ts.map +0 -1
- package/dist/decorators/process.decorator.js +0 -61
- package/dist/decorators/process.decorator.js.map +0 -1
- package/dist/decorators/processor.decorator.d.ts +0 -41
- package/dist/decorators/processor.decorator.d.ts.map +0 -1
- package/dist/decorators/processor.decorator.js +0 -59
- package/dist/decorators/processor.decorator.js.map +0 -1
- package/dist/decorators/queue.decorator.d.ts +0 -35
- package/dist/decorators/queue.decorator.d.ts.map +0 -1
- package/dist/decorators/queue.decorator.js +0 -49
- package/dist/decorators/queue.decorator.js.map +0 -1
- package/dist/events/queue-events.d.ts +0 -32
- package/dist/events/queue-events.d.ts.map +0 -1
- package/dist/events/queue-events.js +0 -103
- package/dist/events/queue-events.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/monitoring/bull-board.d.ts +0 -77
- package/dist/monitoring/bull-board.d.ts.map +0 -1
- package/dist/monitoring/bull-board.js +0 -112
- package/dist/monitoring/bull-board.js.map +0 -1
- package/dist/providers/queue.provider.d.ts +0 -113
- package/dist/providers/queue.provider.d.ts.map +0 -1
- package/dist/providers/queue.provider.js +0 -383
- package/dist/providers/queue.provider.js.map +0 -1
- package/dist/services/queue.service.d.ts +0 -133
- package/dist/services/queue.service.d.ts.map +0 -1
- package/dist/services/queue.service.js +0 -192
- package/dist/services/queue.service.js.map +0 -1
- package/dist/types.d.ts +0 -133
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -5
- package/dist/types.js.map +0 -1
- package/dist/utils/connection.d.ts +0 -47
- package/dist/utils/connection.d.ts.map +0 -1
- package/dist/utils/connection.js +0 -102
- package/dist/utils/connection.js.map +0 -1
- package/dist/utils/validation.d.ts +0 -137
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -156
- package/dist/utils/validation.js.map +0 -1
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* QueueProvider - Main provider for queue lifecycle management
|
|
3
|
-
*
|
|
4
|
-
* Implements OnProviderInit and OnProviderDestroy for Rikta lifecycle integration.
|
|
5
|
-
* Not @Injectable - use createQueueProvider() factory function.
|
|
6
|
-
*/
|
|
7
|
-
import { Container } from '@riktajs/core';
|
|
8
|
-
import { Queue, Worker, QueueEvents } from 'bullmq';
|
|
9
|
-
import { QUEUE_PROVIDER, QUEUE_SERVICE, getQueueToken, getWorkerToken } from '../constants.js';
|
|
10
|
-
import { loadQueueConfig } from '../config/queue.config.js';
|
|
11
|
-
import { RedisConnectionManager, QueueConnectionError } from '../utils/connection.js';
|
|
12
|
-
import { getProcessorOptions, isProcessor } from '../decorators/processor.decorator.js';
|
|
13
|
-
import { getJobHandlers } from '../decorators/process.decorator.js';
|
|
14
|
-
import { getEventHandlers } from '../decorators/events.decorator.js';
|
|
15
|
-
import { publishQueueEvent } from '../events/queue-events.js';
|
|
16
|
-
import { QueueService } from '../services/queue.service.js';
|
|
17
|
-
/**
|
|
18
|
-
* QueueProvider manages the lifecycle of all queues and workers.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* const provider = createQueueProvider({
|
|
23
|
-
* config: { redis: { host: 'localhost', port: 6379 } }
|
|
24
|
-
* });
|
|
25
|
-
*
|
|
26
|
-
* // In Rikta bootstrap:
|
|
27
|
-
* await app.register(provider);
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export class QueueProvider {
|
|
31
|
-
connectionManager = new RedisConnectionManager();
|
|
32
|
-
config;
|
|
33
|
-
queues = new Map();
|
|
34
|
-
workers = new Map();
|
|
35
|
-
processorClasses = [];
|
|
36
|
-
initialized = false;
|
|
37
|
-
eventBus = null;
|
|
38
|
-
options = {
|
|
39
|
-
autoInitialize: true,
|
|
40
|
-
retryAttempts: 0,
|
|
41
|
-
retryDelay: 3000,
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Configure the provider with options
|
|
45
|
-
*/
|
|
46
|
-
configure(options) {
|
|
47
|
-
this.options = { ...this.options, ...options };
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Register processor classes for auto-discovery
|
|
52
|
-
*/
|
|
53
|
-
registerProcessors(...processors) {
|
|
54
|
-
this.processorClasses.push(...processors);
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Set EventBus for event emission (optional)
|
|
59
|
-
*/
|
|
60
|
-
setEventBus(eventBus) {
|
|
61
|
-
this.eventBus = eventBus;
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Initialize all queues and workers (called by Rikta lifecycle)
|
|
66
|
-
*/
|
|
67
|
-
async onProviderInit() {
|
|
68
|
-
console.log('🚀 Queue: Initializing queue system...');
|
|
69
|
-
try {
|
|
70
|
-
// Load configuration
|
|
71
|
-
this.config = loadQueueConfig(this.options.config);
|
|
72
|
-
// Configure Redis connection
|
|
73
|
-
this.connectionManager.configure(this.config.redis);
|
|
74
|
-
// Test connection
|
|
75
|
-
await this.testConnection();
|
|
76
|
-
// Register QueueProvider and QueueService in container FIRST
|
|
77
|
-
// This allows processors to inject QueueService via @Autowired
|
|
78
|
-
this.registerInContainer();
|
|
79
|
-
// Discover and register processors (they can now inject QueueService)
|
|
80
|
-
await this.discoverAndRegisterProcessors();
|
|
81
|
-
this.initialized = true;
|
|
82
|
-
console.log(`✅ Queue: Initialized ${this.queues.size} queue(s), ${this.workers.size} worker(s)`);
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
console.error('❌ Queue: Failed to initialize queue system');
|
|
86
|
-
throw error;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Gracefully shutdown all workers and close connections
|
|
91
|
-
*/
|
|
92
|
-
async onProviderDestroy() {
|
|
93
|
-
if (!this.initialized)
|
|
94
|
-
return;
|
|
95
|
-
console.log('🔌 Queue: Shutting down queue system...');
|
|
96
|
-
try {
|
|
97
|
-
const timeout = this.config.shutdownTimeout || 30000;
|
|
98
|
-
// Close all workers gracefully
|
|
99
|
-
const workerClosePromises = Array.from(this.workers.values()).map(async ({ worker, queueName }) => {
|
|
100
|
-
console.log(` ⏳ Closing worker for ${queueName}...`);
|
|
101
|
-
await Promise.race([
|
|
102
|
-
worker.close(),
|
|
103
|
-
this.delay(timeout),
|
|
104
|
-
]);
|
|
105
|
-
});
|
|
106
|
-
await Promise.all(workerClosePromises);
|
|
107
|
-
// Close all queue event listeners
|
|
108
|
-
for (const { queueEvents } of this.queues.values()) {
|
|
109
|
-
if (queueEvents) {
|
|
110
|
-
await queueEvents.close();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
// Close all queues
|
|
114
|
-
for (const { queue } of this.queues.values()) {
|
|
115
|
-
await queue.close();
|
|
116
|
-
}
|
|
117
|
-
// Close Redis connection
|
|
118
|
-
await this.connectionManager.close();
|
|
119
|
-
this.initialized = false;
|
|
120
|
-
console.log('✅ Queue: Queue system shut down');
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
console.error('❌ Queue: Error during shutdown:', error);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Get a queue by name
|
|
128
|
-
*/
|
|
129
|
-
getQueue(name) {
|
|
130
|
-
return this.queues.get(name)?.queue;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Get all registered queues
|
|
134
|
-
*/
|
|
135
|
-
getAllQueues() {
|
|
136
|
-
return Array.from(this.queues.values()).map(q => q.queue);
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Check if the provider is initialized
|
|
140
|
-
*/
|
|
141
|
-
isInitialized() {
|
|
142
|
-
return this.initialized;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Get configuration
|
|
146
|
-
*/
|
|
147
|
-
getConfig() {
|
|
148
|
-
return this.config;
|
|
149
|
-
}
|
|
150
|
-
// --- Private methods ---
|
|
151
|
-
async testConnection() {
|
|
152
|
-
const client = this.connectionManager.getClient();
|
|
153
|
-
const { retryAttempts = 0, retryDelay = 3000 } = this.options;
|
|
154
|
-
let lastError;
|
|
155
|
-
for (let attempt = 0; attempt <= retryAttempts; attempt++) {
|
|
156
|
-
try {
|
|
157
|
-
await client.ping();
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
catch (error) {
|
|
161
|
-
lastError = error;
|
|
162
|
-
if (attempt < retryAttempts) {
|
|
163
|
-
console.warn(`⚠️ Queue: Connection attempt ${attempt + 1}/${retryAttempts + 1} failed. Retrying in ${retryDelay}ms...`);
|
|
164
|
-
await this.delay(retryDelay);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
throw new QueueConnectionError(`Failed to connect to Redis: ${lastError?.message}`, this.config.redis.host, this.config.redis.port, lastError);
|
|
169
|
-
}
|
|
170
|
-
async discoverAndRegisterProcessors() {
|
|
171
|
-
for (const processorClass of this.processorClasses) {
|
|
172
|
-
if (!isProcessor(processorClass)) {
|
|
173
|
-
console.warn(`⚠️ Queue: ${processorClass.name} is not decorated with @Processor, skipping`);
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
const options = getProcessorOptions(processorClass);
|
|
177
|
-
if (!options)
|
|
178
|
-
continue;
|
|
179
|
-
await this.registerProcessor(processorClass, options);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
async registerProcessor(processorClass, options) {
|
|
183
|
-
const { queueName, concurrency, rateLimiter, workerOptions } = options;
|
|
184
|
-
// Create queue if not exists
|
|
185
|
-
if (!this.queues.has(queueName)) {
|
|
186
|
-
await this.createQueue(queueName);
|
|
187
|
-
}
|
|
188
|
-
// Get job handlers
|
|
189
|
-
const jobHandlers = getJobHandlers(processorClass);
|
|
190
|
-
const eventHandlers = getEventHandlers(processorClass);
|
|
191
|
-
// Create processor instance via DI Container to support @Autowired
|
|
192
|
-
const processor = this.createProcessorInstance(processorClass);
|
|
193
|
-
// Create worker
|
|
194
|
-
const worker = new Worker(queueName, async (job) => {
|
|
195
|
-
// Find handler for this job
|
|
196
|
-
const handler = jobHandlers.find(h => h.name === job.name);
|
|
197
|
-
if (!handler) {
|
|
198
|
-
throw new Error(`No handler found for job: ${job.name}`);
|
|
199
|
-
}
|
|
200
|
-
// Call handler method
|
|
201
|
-
const method = processor[handler.methodName];
|
|
202
|
-
if (typeof method !== 'function') {
|
|
203
|
-
throw new Error(`Handler method ${handler.methodName} not found`);
|
|
204
|
-
}
|
|
205
|
-
return method.call(processor, job);
|
|
206
|
-
}, {
|
|
207
|
-
connection: this.connectionManager.getClient(),
|
|
208
|
-
concurrency: concurrency || this.config.defaultConcurrency || 1,
|
|
209
|
-
limiter: rateLimiter || this.config.defaultRateLimiter,
|
|
210
|
-
...workerOptions,
|
|
211
|
-
});
|
|
212
|
-
// Attach event handlers
|
|
213
|
-
this.attachWorkerEvents(worker, queueName, processor, eventHandlers);
|
|
214
|
-
// Store worker
|
|
215
|
-
this.workers.set(queueName, {
|
|
216
|
-
queueName,
|
|
217
|
-
worker,
|
|
218
|
-
processor,
|
|
219
|
-
processorClass,
|
|
220
|
-
});
|
|
221
|
-
// Register worker in DI container
|
|
222
|
-
this.registerWorkerInContainer(queueName, worker);
|
|
223
|
-
console.log(` 📦 Registered processor for queue: ${queueName} (${jobHandlers.length} handlers)`);
|
|
224
|
-
}
|
|
225
|
-
async createQueue(name) {
|
|
226
|
-
const queue = new Queue(name, {
|
|
227
|
-
connection: this.connectionManager.getClient(),
|
|
228
|
-
});
|
|
229
|
-
// Create queue events for monitoring
|
|
230
|
-
const queueEvents = new QueueEvents(name, {
|
|
231
|
-
connection: this.connectionManager.getClient(),
|
|
232
|
-
});
|
|
233
|
-
this.queues.set(name, { name, queue, queueEvents });
|
|
234
|
-
// Register queue in DI container
|
|
235
|
-
this.registerQueueInContainer(name, queue);
|
|
236
|
-
}
|
|
237
|
-
attachWorkerEvents(worker, queueName, processor, eventHandlers) {
|
|
238
|
-
worker.on('completed', async (job, result) => {
|
|
239
|
-
await this.handleEvent('job:completed', queueName, processor, eventHandlers, job, result);
|
|
240
|
-
});
|
|
241
|
-
worker.on('failed', async (job, error) => {
|
|
242
|
-
await this.handleEvent('job:failed', queueName, processor, eventHandlers, job, error);
|
|
243
|
-
});
|
|
244
|
-
worker.on('progress', async (job, progress) => {
|
|
245
|
-
await this.handleEvent('job:progress', queueName, processor, eventHandlers, job, progress);
|
|
246
|
-
});
|
|
247
|
-
worker.on('stalled', async (jobId) => {
|
|
248
|
-
await this.handleEvent('job:stalled', queueName, processor, eventHandlers, jobId);
|
|
249
|
-
});
|
|
250
|
-
worker.on('ready', async () => {
|
|
251
|
-
await this.handleEvent('worker:ready', queueName, processor, eventHandlers);
|
|
252
|
-
});
|
|
253
|
-
worker.on('error', async (error) => {
|
|
254
|
-
await this.handleEvent('worker:error', queueName, processor, eventHandlers, error);
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
async handleEvent(event, queueName, processor, eventHandlers, ...args) {
|
|
258
|
-
// Call processor event handlers
|
|
259
|
-
const handlers = eventHandlers.filter(h => h.event === event);
|
|
260
|
-
for (const handler of handlers) {
|
|
261
|
-
const method = processor[handler.methodName];
|
|
262
|
-
if (typeof method === 'function') {
|
|
263
|
-
try {
|
|
264
|
-
await method.call(processor, ...args);
|
|
265
|
-
}
|
|
266
|
-
catch (error) {
|
|
267
|
-
console.error(`Error in event handler ${handler.methodName}:`, error);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
// Emit to EventBus if available
|
|
272
|
-
if (this.eventBus) {
|
|
273
|
-
try {
|
|
274
|
-
await publishQueueEvent(this.eventBus, event, queueName, ...args);
|
|
275
|
-
}
|
|
276
|
-
catch {
|
|
277
|
-
// Ignore EventBus errors
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Create a processor instance using the DI Container to support @Autowired
|
|
283
|
-
*/
|
|
284
|
-
createProcessorInstance(processorClass) {
|
|
285
|
-
try {
|
|
286
|
-
const container = Container.getInstance();
|
|
287
|
-
const Constructor = processorClass;
|
|
288
|
-
// Register the processor class if not already registered
|
|
289
|
-
if (!container.has(Constructor)) {
|
|
290
|
-
container.register(Constructor);
|
|
291
|
-
}
|
|
292
|
-
// Resolve the processor through the container to enable DI
|
|
293
|
-
return container.resolve(Constructor);
|
|
294
|
-
}
|
|
295
|
-
catch (error) {
|
|
296
|
-
// Fallback to direct instantiation if container is not available
|
|
297
|
-
console.warn(` ⚠️ DI Container not available for processor ${processorClass.name}, using direct instantiation`);
|
|
298
|
-
return new processorClass();
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Register QueueProvider and QueueService in the DI container.
|
|
303
|
-
* Called early so processors can inject QueueService via @Autowired.
|
|
304
|
-
* Individual queues and workers are registered as they are created.
|
|
305
|
-
*/
|
|
306
|
-
registerInContainer() {
|
|
307
|
-
try {
|
|
308
|
-
const container = Container.getInstance();
|
|
309
|
-
// Register provider
|
|
310
|
-
container.registerValue(QUEUE_PROVIDER, this);
|
|
311
|
-
// Create and register QueueService
|
|
312
|
-
// Note: QueueService accesses queues via provider.getQueue(),
|
|
313
|
-
// so it works even if queues are registered later
|
|
314
|
-
const queueService = new QueueService(this);
|
|
315
|
-
container.registerValue(QUEUE_SERVICE, queueService);
|
|
316
|
-
console.log(' ✅ QueueProvider and QueueService registered in container');
|
|
317
|
-
}
|
|
318
|
-
catch (error) {
|
|
319
|
-
// Container not available, skip registration
|
|
320
|
-
console.warn(' ⚠️ Could not register in container:', error.message);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Register a queue and its worker in the DI container.
|
|
325
|
-
* Called when a queue is created during processor registration.
|
|
326
|
-
*/
|
|
327
|
-
registerQueueInContainer(name, queue) {
|
|
328
|
-
try {
|
|
329
|
-
const container = Container.getInstance();
|
|
330
|
-
container.registerValue(getQueueToken(name), queue);
|
|
331
|
-
}
|
|
332
|
-
catch {
|
|
333
|
-
// Ignore errors - container may not be available
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* Register a worker in the DI container.
|
|
338
|
-
* Called when a worker is created during processor registration.
|
|
339
|
-
*/
|
|
340
|
-
registerWorkerInContainer(name, worker) {
|
|
341
|
-
try {
|
|
342
|
-
const container = Container.getInstance();
|
|
343
|
-
container.registerValue(getWorkerToken(name), worker);
|
|
344
|
-
}
|
|
345
|
-
catch {
|
|
346
|
-
// Ignore errors - container may not be available
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
delay(ms) {
|
|
350
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Factory function to create a QueueProvider
|
|
355
|
-
*/
|
|
356
|
-
export function createQueueProvider(options) {
|
|
357
|
-
const provider = new QueueProvider();
|
|
358
|
-
if (options) {
|
|
359
|
-
provider.configure(options);
|
|
360
|
-
}
|
|
361
|
-
return provider;
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* Error thrown when queue initialization fails
|
|
365
|
-
*/
|
|
366
|
-
export class QueueInitializationError extends Error {
|
|
367
|
-
cause;
|
|
368
|
-
constructor(message, cause) {
|
|
369
|
-
super(message);
|
|
370
|
-
this.cause = cause;
|
|
371
|
-
this.name = 'QueueInitializationError';
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Error thrown when a duplicate queue is detected
|
|
376
|
-
*/
|
|
377
|
-
export class DuplicateQueueError extends Error {
|
|
378
|
-
constructor(queueName) {
|
|
379
|
-
super(`Duplicate queue registration: ${queueName}`);
|
|
380
|
-
this.name = 'DuplicateQueueError';
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
//# sourceMappingURL=queue.provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queue.provider.js","sourceRoot":"","sources":["../../src/providers/queue.provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EACL,cAAc,EACd,aAAa,EACb,aAAa,EACb,cAAc,EACf,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EA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H,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA8B;IAChE,MAAM,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;IACrC,IAAI,OAAO,EAAE,CAAC;QACZ,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACJ;IAA7C,YAAY,OAAe,EAAkB,KAAa;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QAD4B,UAAK,GAAL,KAAK,CAAQ;QAExD,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,SAAiB;QAC3B,KAAK,CAAC,iCAAiC,SAAS,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* QueueService - Injectable service for adding jobs to queues
|
|
3
|
-
*/
|
|
4
|
-
import type { Job, JobsOptions, RepeatOptions } from 'bullmq';
|
|
5
|
-
import type { QueueProvider } from '../providers/queue.provider.js';
|
|
6
|
-
import type { AddJobOptions, ScheduleOptions } from '../types.js';
|
|
7
|
-
/**
|
|
8
|
-
* Service for adding jobs to queues from anywhere in the application.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* @Injectable()
|
|
13
|
-
* class NotificationService {
|
|
14
|
-
* @Autowired()
|
|
15
|
-
* private queueService!: QueueService;
|
|
16
|
-
*
|
|
17
|
-
* async sendNotification(userId: string, message: string) {
|
|
18
|
-
* await this.queueService.addJob('notifications', 'send', {
|
|
19
|
-
* userId,
|
|
20
|
-
* message,
|
|
21
|
-
* });
|
|
22
|
-
* }
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export declare class QueueService {
|
|
27
|
-
private readonly provider;
|
|
28
|
-
constructor(provider: QueueProvider);
|
|
29
|
-
/**
|
|
30
|
-
* Add a job to a queue
|
|
31
|
-
*
|
|
32
|
-
* @param queueName - Name of the queue
|
|
33
|
-
* @param jobName - Name of the job (matches @Process decorator)
|
|
34
|
-
* @param data - Job payload data
|
|
35
|
-
* @param options - Optional job options
|
|
36
|
-
* @returns The created job
|
|
37
|
-
*/
|
|
38
|
-
addJob<TData = unknown, TResult = unknown>(queueName: string, jobName: string, data: TData, options?: AddJobOptions): Promise<Job<TData, TResult>>;
|
|
39
|
-
/**
|
|
40
|
-
* Add multiple jobs to a queue in bulk
|
|
41
|
-
*
|
|
42
|
-
* @param queueName - Name of the queue
|
|
43
|
-
* @param jobs - Array of jobs to add
|
|
44
|
-
* @returns Array of created jobs
|
|
45
|
-
*/
|
|
46
|
-
addJobs<TData = unknown, TResult = unknown>(queueName: string, jobs: Array<{
|
|
47
|
-
name: string;
|
|
48
|
-
data: TData;
|
|
49
|
-
options?: JobsOptions;
|
|
50
|
-
}>): Promise<Job<TData, TResult>[]>;
|
|
51
|
-
/**
|
|
52
|
-
* Add a delayed job
|
|
53
|
-
*
|
|
54
|
-
* @param queueName - Name of the queue
|
|
55
|
-
* @param jobName - Name of the job
|
|
56
|
-
* @param data - Job payload data
|
|
57
|
-
* @param delay - Delay in milliseconds
|
|
58
|
-
* @param options - Optional job options
|
|
59
|
-
*/
|
|
60
|
-
addDelayedJob<TData = unknown, TResult = unknown>(queueName: string, jobName: string, data: TData, delay: number, options?: JobsOptions): Promise<Job<TData, TResult>>;
|
|
61
|
-
/**
|
|
62
|
-
* Add a repeatable job (scheduled)
|
|
63
|
-
*
|
|
64
|
-
* @param queueName - Name of the queue
|
|
65
|
-
* @param jobName - Name of the job
|
|
66
|
-
* @param data - Job payload data
|
|
67
|
-
* @param repeat - Repeat options (cron pattern, interval, etc.)
|
|
68
|
-
* @param options - Optional schedule options
|
|
69
|
-
*/
|
|
70
|
-
addRepeatableJob<TData = unknown, TResult = unknown>(queueName: string, jobName: string, data: TData, repeat: RepeatOptions, options?: ScheduleOptions): Promise<Job<TData, TResult>>;
|
|
71
|
-
/**
|
|
72
|
-
* Remove a repeatable job
|
|
73
|
-
*
|
|
74
|
-
* @param queueName - Name of the queue
|
|
75
|
-
* @param jobName - Name of the job
|
|
76
|
-
* @param repeat - The repeat options used when creating the job
|
|
77
|
-
*/
|
|
78
|
-
removeRepeatableJob(queueName: string, jobName: string, repeat: RepeatOptions): Promise<boolean>;
|
|
79
|
-
/**
|
|
80
|
-
* Get a job by ID
|
|
81
|
-
*
|
|
82
|
-
* @param queueName - Name of the queue
|
|
83
|
-
* @param jobId - Job ID
|
|
84
|
-
*/
|
|
85
|
-
getJob<TData = unknown, TResult = unknown>(queueName: string, jobId: string): Promise<Job<TData, TResult> | undefined>;
|
|
86
|
-
/**
|
|
87
|
-
* Get queue statistics
|
|
88
|
-
*
|
|
89
|
-
* @param queueName - Name of the queue
|
|
90
|
-
*/
|
|
91
|
-
getQueueStats(queueName: string): Promise<{
|
|
92
|
-
waiting: number;
|
|
93
|
-
active: number;
|
|
94
|
-
completed: number;
|
|
95
|
-
failed: number;
|
|
96
|
-
delayed: number;
|
|
97
|
-
paused: number;
|
|
98
|
-
}>;
|
|
99
|
-
/**
|
|
100
|
-
* Pause a queue
|
|
101
|
-
*/
|
|
102
|
-
pauseQueue(queueName: string): Promise<void>;
|
|
103
|
-
/**
|
|
104
|
-
* Resume a queue
|
|
105
|
-
*/
|
|
106
|
-
resumeQueue(queueName: string): Promise<void>;
|
|
107
|
-
/**
|
|
108
|
-
* Clear all jobs from a queue
|
|
109
|
-
*
|
|
110
|
-
* @param queueName - Name of the queue
|
|
111
|
-
* @param status - Which jobs to clear (default: all)
|
|
112
|
-
*/
|
|
113
|
-
clearQueue(queueName: string, status?: 'completed' | 'failed' | 'delayed' | 'wait' | 'active'): Promise<void>;
|
|
114
|
-
/**
|
|
115
|
-
* Get all queue names
|
|
116
|
-
*/
|
|
117
|
-
getQueueNames(): string[];
|
|
118
|
-
private getQueueOrThrow;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Error thrown when a queue is not found
|
|
122
|
-
*/
|
|
123
|
-
export declare class QueueNotFoundError extends Error {
|
|
124
|
-
constructor(queueName: string);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Error thrown when job validation fails
|
|
128
|
-
*/
|
|
129
|
-
export declare class JobValidationError extends Error {
|
|
130
|
-
readonly errors: unknown[];
|
|
131
|
-
constructor(message: string, errors: unknown[]);
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=queue.service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queue.service.d.ts","sourceRoot":"","sources":["../../src/services/queue.service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAElE;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,aAAa;IAEpD;;;;;;;;OAQG;IACG,MAAM,CAAC,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAC7C,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,KAAK,EACX,OAAO,CAAC,EAAE,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