huge refactor done
This commit is contained in:
parent
843a7b9b9b
commit
60d7de1da8
16 changed files with 472 additions and 443 deletions
|
|
@ -45,6 +45,13 @@ export class Queue {
|
|||
this.redisConfig = redisConfig;
|
||||
this.logger = logger || console;
|
||||
this.handlerRegistry = config.handlerRegistry;
|
||||
|
||||
this.logger.debug('Queue constructor called', {
|
||||
queueName,
|
||||
hasHandlerRegistry: !!config.handlerRegistry,
|
||||
handlerRegistryType: config.handlerRegistry ? typeof config.handlerRegistry : 'undefined',
|
||||
configKeys: Object.keys(config),
|
||||
});
|
||||
|
||||
const connection = getRedisConnection(redisConfig);
|
||||
|
||||
|
|
@ -70,7 +77,20 @@ export class Queue {
|
|||
|
||||
// Start workers if requested and not explicitly disabled
|
||||
if (config.workers && config.workers > 0 && config.startWorker !== false) {
|
||||
this.logger.info('Starting workers for queue', {
|
||||
queueName,
|
||||
workers: config.workers,
|
||||
concurrency: config.concurrency || 1,
|
||||
hasHandlerRegistry: !!this.handlerRegistry,
|
||||
});
|
||||
this.startWorkers(config.workers, config.concurrency || 1);
|
||||
} else {
|
||||
this.logger.info('Not starting workers for queue', {
|
||||
queueName,
|
||||
workers: config.workers || 0,
|
||||
startWorker: config.startWorker,
|
||||
hasHandlerRegistry: !!this.handlerRegistry,
|
||||
});
|
||||
}
|
||||
|
||||
this.logger.trace('Queue created', {
|
||||
|
|
@ -288,6 +308,12 @@ export class Queue {
|
|||
maxStalledCount: 3,
|
||||
stalledInterval: 30000,
|
||||
});
|
||||
|
||||
this.logger.info(`Starting worker ${i + 1}/${workerCount} for queue`, {
|
||||
queueName: this.queueName,
|
||||
workerId: i,
|
||||
concurrency,
|
||||
});
|
||||
|
||||
// Setup worker event handlers
|
||||
worker.on('completed', job => {
|
||||
|
|
@ -345,6 +371,14 @@ export class Queue {
|
|||
if (!this.handlerRegistry) {
|
||||
throw new Error('Handler registry not configured for worker processing');
|
||||
}
|
||||
|
||||
this.logger.debug('Looking up handler in registry', {
|
||||
handler,
|
||||
operation,
|
||||
queueName: this.queueName,
|
||||
registeredHandlers: this.handlerRegistry.getHandlerNames(),
|
||||
});
|
||||
|
||||
const jobHandler = this.handlerRegistry.getOperation(handler, operation);
|
||||
|
||||
if (!jobHandler) {
|
||||
|
|
@ -381,6 +415,13 @@ export class Queue {
|
|||
this.logger.warn('Workers already started for queue', { queueName: this.queueName });
|
||||
return;
|
||||
}
|
||||
|
||||
this.logger.info('Starting workers manually', {
|
||||
queueName: this.queueName,
|
||||
workerCount,
|
||||
concurrency,
|
||||
hasHandlerRegistry: !!this.handlerRegistry,
|
||||
});
|
||||
|
||||
// Initialize queue events if not already done
|
||||
if (!this.queueEvents) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue