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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@argos-js/queue

v0.1.2

Published

Event-driven asynchronous job queue with transactional adapters and concurrency controls for Argos-JS

Readme

@argos-js/queue

Event-driven asynchronous job queue with transactional adapters, concurrency controls, backoff retries, and graceful shutdown for the Argos-JS framework.


Features

  • Strict Conceptual Separation: Dedicated purely to event-driven, on-demand jobs (emails, webhooks, heavy background processing).
  • Zero External Required Dependencies: Out-of-the-box support for MemoryAdapter (in-memory, testing, development) and DatabaseAdapter (@argos-js/data transactional with SELECT ... FOR UPDATE SKIP LOCKED on PostgreSQL/MySQL, or atomic transactions on SQLite).
  • Pluggable Architecture: Ready for future native Rust engines, ArgosDB, or optional Redis drivers without forcing BullMQ or Redis.
  • Type-Safe Job Definitions: defineJob<TPayload>() with inferred payload typing and cooperative JobContext (jobId, attempt, signal, progress).
  • Cooperative Graceful Shutdown: Listens to SIGTERM/SIGINT, propagates AbortSignal to active jobs, and drains running tasks before terminating.
  • Configurable Backoff Retries: Supports exponential and fixed backoff strategies.

Installation

pnpm add @argos-js/queue

Quick Start

1. Defining a Job

import { defineJob } from '@argos-js/queue';

export interface SendWelcomeEmailPayload {
  to: string;
  name: string;
}

export const sendWelcomeEmailJob = defineJob<SendWelcomeEmailPayload>({
  name: 'send-welcome-email',
  attempts: 3,
  backoff: {
    type: 'exponential',
    delayMs: 1000, // 1s, 2s, 4s...
  },
  handler: async (payload, context) => {
    console.log(`[Job ${context.jobId}] Attempt ${context.attempt} sending email to ${payload.to}`);

    // Cooperative cancellation check
    if (context.signal.aborted) {
      throw new Error('Worker is shutting down');
    }

    await context.progress(25);
    // Send email logic...
    await context.progress(100);
  },
});

2. Dispatching a Job

// Dispatch immediately
const jobId = await sendWelcomeEmailJob.dispatch({
  to: '[email protected]',
  name: 'Alice',
});

// Dispatch with delay or specific queue
const delayedJobId = await sendWelcomeEmailJob.dispatch(
  { to: '[email protected]', name: 'Bob' },
  { delayMs: 60000, queue: 'high-priority' }
);

3. Running a Queue Worker

import { QueueWorker, DatabaseAdapter, setDefaultQueueAdapter } from '@argos-js/queue';
import { createDatabase } from '@argos-js/data';

// Optional: Use persistent database adapter
const db = createDatabase({
  driver: 'postgres',
  connectionString: process.env.DATABASE_URL,
});

const adapter = new DatabaseAdapter(db);
setDefaultQueueAdapter(adapter);

const worker = new QueueWorker({
  concurrency: 4,
  queues: ['high-priority', 'default'],
  adapter,
});

// Setup SIGTERM / SIGINT graceful handling
worker.setupSignalHandlers();

await worker.start();

CLI Management

The official Argos CLI provides semantic commands to control queue workers:

# Start queue workers
argos queue start --workers=4 --queues=high,default

# Check queue status (pending, processing, completed, failed)
argos queue status

# Clear jobs from a specific queue
argos queue clear default

Production Deployment

Systemd Service (/etc/systemd/system/argos-queue.service)

[Unit]
Description=Argos-JS Background Queue Worker
After=network.target

[Service]
Type=simple
User=argos
WorkingDirectory=/var/www/my-argos-app
Environment=NODE_ENV=production
ExecStart=/usr/bin/node ./dist/app/index.js --worker
Restart=always
RestartSec=5
KillSignal=SIGTERM
TimeoutStopSec=30

[Install]
WantedBy=multi-user.target

Docker Container

FROM node:20-alpine AS runner
WORKDIR /app

COPY package.json pnpm-lock.yaml ./
RUN npm install -g pnpm && pnpm install --prod

COPY dist ./dist

ENV NODE_ENV=production
STOPSIGNAL SIGTERM

CMD ["node", "./node_modules/@argos-js/cli/bin/argos.js", "queue", "start", "--workers=4"]