/** * QueueProcessor * * Processes queued file operations with concurrency control and retry logic. * * Features: * - Concurrent worker management (configurable concurrency) * - Automatic retry with exponential backoff * - Event emission for operation lifecycle * - Graceful start/stop * - Error handling and logging * * @module @plyaz/storage/queue */ import type { StorageQueueProcessFunction, StorageQueueProcessorConfig } from '@plyaz/types/storage'; import type { EventManager } from '../core/EventManager'; import type { InMemoryQueue } from './InMemoryQueue'; /** * Queue processor for concurrent job processing * * @example * ```typescript * const queue = new InMemoryQueue({ logger }); * const processor = new QueueProcessor( * queue, * async (operation) => { * // Process the operation * await storageService.uploadFile(operation.uploadParams); * }, * { * concurrency: 5, * maxRetries: 3, * eventManager, * logger, * } * ); * * processor.start(); * * // Later... * await processor.stop(); * ``` */ export declare class QueueProcessor { private running; private workers; private intervalHandle?; private readonly queue; private readonly processFunction; private readonly eventManager?; private readonly logger?; private readonly config; constructor(queue: InMemoryQueue, processFunction: StorageQueueProcessFunction, config?: StorageQueueProcessorConfig); /** * Start the queue processor * Begins polling the queue and processing operations */ start(): void; /** * Stop the queue processor * Waits for all active workers to complete */ stop(): Promise; /** * Check if processor is running */ isRunning(): boolean; /** * Get number of active workers */ getActiveWorkerCount(): number; /** * Tick function - spawns workers up to concurrency limit */ private tick; /** * Process next operation from queue */ private processNext; /** * Handle processing error with retry logic */ private handleProcessingError; /** * Get processor statistics */ getStatistics(): { running: boolean; activeWorkers: number; queueStatistics: ReturnType; }; }