/** * InMemoryQueue * * In-memory queue for file operations with priority-based processing. * * Features: * - Priority-based queue (high, normal, low) * - FIFO ordering within same priority * - Statistics tracking (queued, processed, failed) * - Processing state management * * @module @plyaz/storage/queue */ import type { StorageQueuedOperation, StorageQueueStatistics, STORAGE_QUEUE_PRIORITY } from '@plyaz/types/storage'; import type { LoggerInterface } from '@plyaz/types'; /** * In-memory queue for file operations * * @example * ```typescript * const queue = new InMemoryQueue({ logger }); * * await queue.enqueue({ * id: '123', * type: 'upload', * uploadParams: { ... }, * priority: 'high', * retryCount: 0, * maxRetries: 3, * createdAt: new Date(), * }); * * const operation = await queue.dequeue(); * ``` */ export declare class InMemoryQueue { private queue; private processing; private totalQueued; private processedCount; private failedCount; private readonly logger?; constructor(config?: { logger?: LoggerInterface; }); /** * Add operation to queue * High priority operations are inserted at the front * Normal and low priority are added to the back */ enqueue(operation: StorageQueuedOperation): Promise; /** * Remove and return next operation from queue * Returns null if queue is empty */ dequeue(): Promise; /** * Get current queue size */ size(): number; /** * Check if queue is empty */ isEmpty(): boolean; /** * Set processing state */ setProcessing(processing: boolean): void; /** * Check if queue is currently being processed */ isProcessing(): boolean; /** * Increment processed count */ incrementProcessed(): void; /** * Increment failed count */ incrementFailed(): void; /** * Get queue statistics */ getStatistics(): StorageQueueStatistics; /** * Clear all operations from queue * Useful for testing or emergency shutdown */ clear(): void; /** * Get all operations in queue (for debugging/monitoring) * Returns a copy to prevent external modification */ getAll(): StorageQueuedOperation[]; /** * Peek at next operation without removing it */ peek(): StorageQueuedOperation | null; /** * Remove specific operation by ID * Returns true if operation was found and removed */ remove(operationId: string): boolean; /** * Find operation by ID */ find(operationId: string): StorageQueuedOperation | undefined; /** * Get operations by type */ getByType(type: StorageQueuedOperation['type']): StorageQueuedOperation[]; /** * Get operations by priority */ getByPriority(priority: STORAGE_QUEUE_PRIORITY): StorageQueuedOperation[]; }