UNPKG

queuex-sdk

Version:

A TypeScript-based queue management SDK with Redis support

36 lines (35 loc) 1.34 kB
import { Job } from '../models/job'; import { QueueXEvent } from '../lib'; import { QueueStrategy } from '../models/queue'; /** * Redis-based storage for jobs and events using Streams for logs. */ export declare class RedisStorage { private client; constructor(connectionString: string); /** * Enqueues a job using the specified queue strategy. * * Strategies: * - FIFO: Uses RPUSH to add jobs to the end of the list * - LIFO: Uses LPUSH to add jobs to the beginning of the list * - PRIORITY: Uses ZADD with priority as score * - ROUND_ROBIN: Uses RPUSH with a circular buffer */ enqueueJob(job: Job, strategy?: QueueStrategy): Promise<void>; /** * Gets the next job based on the queue strategy. */ getNextJob(queue: string, strategy?: QueueStrategy): Promise<Job | null>; /** * Converts priority level to a numeric score for Redis sorted sets. */ private getPriorityScore; scheduleJob(job: Job): Promise<void>; saveJobResult(job: Job): Promise<void>; logEvent(event: QueueXEvent, job: Job): Promise<void>; getEvents(jobId: string): Promise<string[]>; getScheduledJobs(queue: string, maxScore: number): Promise<string[]>; removeScheduledJob(queue: string, jobId: string): Promise<void>; disconnect(): Promise<void>; }