npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

queuex-sdk

v0.9.9

Published

A TypeScript-based queue management SDK with Redis support

Readme

QueueX 🚀

A powerful, feature-rich job queue system for Node.js with advanced retry strategies, job chaining, and intelligent job processing.

TypeScript Redis License NPM Version

✨ Features

  • 🔄 Advanced Retry Strategies

    • Exponential, Linear, and Fixed backoff
    • Configurable delays and attempts
    • Maximum retry limit
  • ⏱️ Smart Job Processing

    • Job timeout handling
    • Time-to-live (TTL) support
    • Multiple queue processing strategies
    • Concurrent job execution
  • 🔗 Job Dependencies & Chaining

    • Sequential job execution
    • Result passing between jobs
    • Complex workflow support
    • Dependency graph management
  • 📊 Queue Management

    • FIFO/LIFO processing
    • Priority queues
    • Round-robin distribution
    • Rate limiting

🚀 Quick Start

npm install queuex-sdk
import { QueueX } from 'queuex-sdk';

// Initialize QueueX
const queuex = new QueueX({ 
  redisConnection: 'redis://localhost:6379' 
});

// Create a queue
await queuex.createQueue('emailQueue', { 
  maxConcurrency: 5 
});

// Add a job with retry strategy
await queuex.enqueue('emailQueue', 
  { to: '[email protected]', subject: 'Welcome!' },
  {
    retries: 3,
    backoff: {
      type: 'exponential',
      delay: 1000,
      maxDelay: 30000
    }
  }
);

// Process jobs
queuex.startWorker('emailQueue', async (job) => {
  await sendEmail(job.data);
  return { sent: true };
});

🔥 Advanced Features

Retry Strategies

// Exponential Backoff
await queuex.enqueue('queue', data, {
  retries: 5,
  backoff: { 
    type: 'exponential', 
    delay: 1000,
    maxDelay: 60000 
  }
});

// Linear Backoff
await queuex.enqueue('queue', data, {
  retries: 3,
  backoff: { 
    type: 'linear', 
    delay: 5000 
  }
});

// Fixed Delay
await queuex.enqueue('queue', data, {
  retries: 2,
  backoff: { 
    type: 'fixed', 
    delay: 10000 
  }
});

Job Timeouts & TTL

// Job with timeout
await queuex.enqueue('queue', data, {
  timeout: 5000  // 5 seconds timeout
});

// Job with TTL
await queuex.enqueue('queue', data, {
  ttl: 3600000  // 1 hour TTL
});

// Combined options
await queuex.enqueue('queue', data, {
  timeout: 5000,
  ttl: 3600000,
  retries: 3,
  backoff: { type: 'exponential', delay: 1000 }
});

Job Chaining

// Create a chain of jobs
await queuex.enqueue('videoQueue', { videoId: '123' }, {
  chain: [
    {
      data: { step: 'compress' },
      options: { 
        priority: 'high',
        timeout: 300000 
      }
    },
    {
      data: { step: 'thumbnail' },
      options: { 
        retries: 2,
        backoff: { type: 'linear', delay: 5000 }
      }
    }
  ]
});

// Access previous job's result
queuex.startWorker('videoQueue', async (job) => {
  if (job.context) {
    console.log('Previous job result:', job.context);
  }
  // Process current job...
});

Queue Processing Strategies

// FIFO Queue (default)
await queuex.createQueue('fifoQueue', { 
  strategy: QueueStrategy.FIFO 
});

// LIFO Queue
await queuex.createQueue('lifoQueue', { 
  strategy: QueueStrategy.LIFO 
});

// Priority Queue
await queuex.createQueue('priorityQueue', { 
  strategy: QueueStrategy.PRIORITY 
});

// Round Robin Queue
await queuex.createQueue('roundRobinQueue', { 
  strategy: QueueStrategy.ROUND_ROBIN 
});

📊 Event Handling

queuex.on('jobStarted', (job) => {
  console.log(`Job ${job.id} started`);
});

queuex.on('jobCompleted', (job) => {
  console.log(`Job ${job.id} completed`);
});

queuex.on('jobFailed', (job) => {
  console.error(`Job ${job.id} failed:`, job.logs);
});

queuex.on('jobDelayed', (job) => {
  console.log(`Job ${job.id} delayed until:`, 
    new Date(job.scheduledAt!).toISOString()
  );
});

🔧 Configuration Options

Job Options

interface JobOptions {
  priority?: 'high' | 'medium' | 'low';
  retries?: number;
  backoff?: {
    type: 'exponential' | 'linear' | 'fixed';
    delay: number;
    maxDelay?: number;
  };
  timeout?: number;
  ttl?: number;
  delay?: number;
  concurrency?: number;
  dependsOn?: string[];
  cron?: string;
  chain?: Array<{
    data: any;
    options?: JobOptions;
  }>;
}

Queue Options

interface QueueOptions {
  maxConcurrency?: number;
  strategy?: QueueStrategy;
  rateLimit?: {
    max: number;
    interval: number;
  };
}

📚 Best Practices

  1. Retry Strategies

    • Use exponential backoff for network operations
    • Use linear backoff for resource-intensive tasks
    • Use fixed delay for scheduled retries
  2. Timeouts & TTL

    • Set reasonable timeouts based on operation type
    • Use TTL for time-sensitive tasks
    • Consider queue processing time in TTL calculations
  3. Job Chaining

    • Keep chains focused and minimal
    • Handle errors appropriately in each step
    • Use context passing judiciously
  4. Queue Strategies

    • Use FIFO for standard operations
    • Use LIFO for real-time updates
    • Use Priority for important tasks
    • Use Round Robin for fair resource distribution