removed queue factory
This commit is contained in:
parent
7b0c7d12fa
commit
2e223b0d3c
2 changed files with 1 additions and 90 deletions
|
|
@ -7,14 +7,7 @@ export { handlerRegistry } from './handler-registry';
|
|||
export { processBatchJob, processItems } from './batch-processor';
|
||||
|
||||
// Queue factory functions
|
||||
export {
|
||||
initializeQueueSystem,
|
||||
getQueue,
|
||||
processItemsWithQueue,
|
||||
getActiveQueueNames,
|
||||
getQueueManager,
|
||||
shutdownAllQueues
|
||||
} from './queue-factory';
|
||||
// QueueFactory removed - use QueueManager directly
|
||||
|
||||
// DLQ handling
|
||||
export { DeadLetterQueueHandler, DeadLetterQueueHandler as DLQHandler } from './dlq-handler';
|
||||
|
|
|
|||
|
|
@ -1,82 +0,0 @@
|
|||
import { getLogger } from '@stock-bot/logger';
|
||||
import { QueueManager } from './queue-manager';
|
||||
import { Queue } from './queue';
|
||||
import { processItems } from './batch-processor';
|
||||
import type { ProcessOptions, BatchResult, QueueManagerConfig, RedisConfig, JobOptions } from './types';
|
||||
|
||||
const logger = getLogger('queue-factory');
|
||||
|
||||
/**
|
||||
* Initialize the queue system with global configuration
|
||||
* This now uses the singleton QueueManager pattern
|
||||
*/
|
||||
export async function initializeQueueSystem(config: {
|
||||
redis: RedisConfig;
|
||||
defaultJobOptions?: JobOptions;
|
||||
workers?: number;
|
||||
concurrency?: number;
|
||||
}): Promise<void> {
|
||||
logger.info('Initializing global queue system...');
|
||||
|
||||
const queueManagerConfig: QueueManagerConfig = {
|
||||
redis: config.redis,
|
||||
defaultQueueOptions: {
|
||||
defaultJobOptions: config.defaultJobOptions,
|
||||
workers: config.workers || 5,
|
||||
concurrency: config.concurrency || 20,
|
||||
},
|
||||
};
|
||||
|
||||
// Initialize the singleton QueueManager
|
||||
QueueManager.initialize(queueManagerConfig);
|
||||
|
||||
logger.info('Queue system initialized with singleton QueueManager');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or create a queue for the given queue name
|
||||
* Now uses the singleton QueueManager
|
||||
*/
|
||||
export function getQueue(queueName: string): Queue {
|
||||
const queueManager = QueueManager.getInstance();
|
||||
return queueManager.getQueue(queueName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process items using the specified queue
|
||||
* Now uses the batch processor directly
|
||||
*/
|
||||
export async function processItemsWithQueue<T>(
|
||||
queueName: string,
|
||||
items: T[],
|
||||
options: ProcessOptions
|
||||
): Promise<BatchResult> {
|
||||
return processItems(items, queueName, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all active queue names
|
||||
*/
|
||||
export function getActiveQueueNames(): string[] {
|
||||
const queueManager = QueueManager.getInstance();
|
||||
return queueManager.getQueueNames();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the global queue manager (for advanced operations)
|
||||
*/
|
||||
export function getQueueManager(): QueueManager {
|
||||
return QueueManager.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown all queues and the queue manager
|
||||
*/
|
||||
export async function shutdownAllQueues(): Promise<void> {
|
||||
logger.info('Shutting down all queues...');
|
||||
|
||||
// Reset the singleton QueueManager (handles all cleanup)
|
||||
await QueueManager.reset();
|
||||
|
||||
logger.info('All queues shut down');
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue