UNPKG

@backgroundjs/core

Version:

An extendible background job queue for js/ts applications

43 lines (42 loc) 1.36 kB
import { Job } from "../types"; import { JobQueue } from "./job-queue"; import { RedisStorage } from "../storage/redis-storage"; /** * DistributedJobQueue extends JobQueue to provide distributed processing * capabilities across multiple instances/processes using Redis atomic operations. */ export declare class DistributedJobQueue extends JobQueue { private readonly redisStorage; private readonly jobTTL; private queueName; /** * Create a distributed job queue * * @param storage - A storage implementation that supports atomic operations * @param options - Configuration options */ constructor(storage: RedisStorage, options?: { concurrency?: number; name?: string; jobTTL?: number; processingInterval?: number; maxRetries?: number; logging?: boolean; intelligentPolling?: boolean; minInterval?: number; maxInterval?: number; maxEmptyPolls?: number; loadFactor?: number; standAlone?: boolean; }); /** * Process jobs with distributed locking * Override the parent's protected method */ protected processNextBatch(): Promise<void>; /** * Process a single job with locking * This is called by the parent class */ protected processJob(job: Job): Promise<void>; }