UNPKG

@eleven-am/transcoder

Version:

High-performance HLS transcoding library with hardware acceleration, intelligent client management, and distributed processing support for Node.js

87 lines 2.44 kB
import { TaskEither } from '@eleven-am/fp'; import { TranscodeJob } from './types'; import { ExtendedEventEmitter } from './utils'; interface JobProcessorEvents { 'job:started': TranscodeJob; 'job:completed': TranscodeJob; 'job:failed': { job: TranscodeJob; error: Error; }; 'queue:full': { size: number; maxSize: number; }; 'concurrency:changed': { current: number; max: number; }; } /** * JobProcessor - Manages transcoding job execution with concurrency control * * This class provides a queue-based system for managing FFmpeg transcoding jobs, * ensuring system resources aren't overwhelmed by limiting concurrent executions. */ export declare class JobProcessor extends ExtendedEventEmitter<JobProcessorEvents> { private maxConcurrentJobs; private readonly maxQueueSize; private readonly queue; private activeJobs; private disposed; private lastCpuInfo; private lastMeasureTime; constructor(maxConcurrentJobs?: number, maxQueueSize?: number); /** * Submit a job for processing * @param job The transcode job to process * @returns A promise that resolves when the job completes */ submitJob(job: TranscodeJob): TaskEither<void>; /** * Get current queue status */ getStatus(): { queueLength: number; activeJobs: number; maxConcurrentJobs: number; isProcessing: boolean; }; /** * Update the maximum number of concurrent jobs * @param newMax New maximum concurrent jobs */ setMaxConcurrentJobs(newMax: number): void; /** * Clear all pending jobs from the queue */ clearQueue(): void; /** * Dispose of the job processor */ dispose(): void; /** * Process the next job in the queue if possible */ private processNextJob; /** * Execute a single job */ private executeJob; /** * Handle job completion and process next job */ private jobCompleted; /** * Get a system load for dynamic concurrency adjustment * @returns System load percentage (0-100) */ private getSystemLoad; /** * Dynamically adjust concurrency based on system load * Call this periodically if you want automatic adjustment */ adjustConcurrencyBasedOnLoad(): void; } export {}; //# sourceMappingURL=jobProcessor.d.ts.map