added batching mess

This commit is contained in:
Bojan Kucera 2025-06-08 23:30:46 -04:00
parent fe96cf6679
commit 22992cd393
4 changed files with 603 additions and 95 deletions

View file

@ -47,7 +47,7 @@ export class QueueService {
};
// Worker configuration
const workerCount = parseInt(process.env.WORKER_COUNT || '4');
const workerCount = parseInt(process.env.WORKER_COUNT || '5');
const concurrencyPerWorker = parseInt(process.env.WORKER_CONCURRENCY || '20');
this.logger.info('Connecting to Redis/Dragonfly', connection);
@ -180,6 +180,10 @@ export class QueueService {
throw error;
}
}
async addBulk(jobs: any[]) : Promise<any[]> {
return await this.queue.addBulk(jobs)
}
private setupEventListeners() {
this.queueEvents.on('completed', (job) => {
this.logger.info('Job completed', { id: job.jobId });
@ -396,6 +400,13 @@ export class QueueService {
delayed: delayed.length
};
}
async drainQueue() {
if (!this.isInitialized) {
await this.queue.drain()
}
}
async getQueueStatus() {
if (!this.isInitialized) {
throw new Error('Queue service not initialized. Call initialize() first.');
@ -412,12 +423,14 @@ export class QueueService {
}
};
}
getWorkerCount() {
if (!this.isInitialized) {
return 0;
}
return this.workers.length;
}
getRegisteredProviders() {
return providerRegistry.getProviders().map(({ key, config }) => ({
key,