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

@azlib/queue

v1.0.1

Published

Provider-agnostic background task queue implementing retry policies, dead-letter routing, and dashboard query interfaces.

Readme

@azlib/queue

Provider-agnostic background task queue implementing retry policies, dead-letter routing, and dashboard query interfaces.

Capabilities

  • Asynchronous task enqueue and claim workflows
  • Retry policies supporting fixed, exponential, and jittered backoffs
  • Dead-letter routing (DLQ) with remediation operator actions
  • In-process or database-backed task state durability (SQL persistence)
  • Pluggable logging for enqueue, claim, retry, ack, and dead-letter transitions
  • Provider switching (e.g. Memory, AWS SQS) under a stable, uniform API

AI Agent Quick Reference

Core Exports

| Export | Type | Description | | --- | --- | --- | | createQueueService(options: QueueServiceOptions): QueueService | Function | Instantiates the core queue manager instance. | | createProviderFromEnv(env: Record<string, string>): QueueProvider | Function | Factory generating a queue provider (Memory vs AWS SQS) from env config. | | createRetryPolicyEngine(policy: RetryPolicy) | Function | Low-level calculator of next-run timestamps and backoffs. | | createConsoleQueueLogger() | Function | Simple logger output formatter for debugging task runs. |

Core Types & Signatures

  • QueueService:
    • enqueue(input: EnqueueInput): Promise<EnqueueResult>
    • consume(queueName: string, worker: (task: ClaimedMessage, ctx: WorkerContext) => Promise<void>): Promise<() => void> (returns shutdown unsubscriber)
    • getDashboardQueries(): Returns service interfaces for querying status stats, attempts, and DLQ remediation.
  • QueueServiceOptions:
    • provider: QueueProvider
    • defaultQueue?: string
    • retryPolicy?: RetryPolicy
    • persistence?: PersistenceConfig (durable SQL persistence from @azlib/persistence)
    • logger?: QueueLogger
  • EnqueueInput:
    • idempotencyKey?: string
    • payloadRef: any (JSON-serializable data)
    • queueName?: string
  • RetryPolicy:
    • maxAttempts: number
    • backoffType: "fixed" | "exponential" | "exponential-jitter"
    • baseDelayMs: number
    • maxDelayMs: number

Basic Usage (Memory Provider)

import { createQueueService } from "@azlib/queue";
import { createProviderFromEnv } from "@azlib/queue/providers";

const queue = createQueueService({
  provider: createProviderFromEnv({ QUEUE_PROVIDER: "memory" }),
  defaultQueue: "heavy-jobs",
  retryPolicy: {
    maxAttempts: 3,
    backoffType: "exponential-jitter",
    baseDelayMs: 1000,
    maxDelayMs: 30_000,
  },
});

// Enqueue a job
const result = await queue.enqueue({
  idempotencyKey: "invoice_123",
  payloadRef: { invoiceId: 123 },
});

Worker / Consumer Flow

// Start worker
const unsubscribe = await queue.consume("heavy-jobs", async (task, ctx) => {
  try {
    await processInvoice(task.payloadRef.invoiceId);
    await ctx.ack(); // success
  } catch (error) {
    await ctx.fail(error); // triggers retry policy or moves to DLQ
  }
});

// Call unsubscribe() on process shutdown

Behavioral Gotchas

  • Default Logger Binding: If no logger is passed to the options, the service will fall back to using @azlib/logger automatically.
  • Idempotency Guard: If SQL persistence is not configured, the default memory-based idempotency guard is transient and resets on application restart.
  • DLQ State Transitions: Tasks enter the Dead-Letter Queue (DLQ) status immediately once maxAttempts are exhausted. They must be resolved manually or requeued using the Dashboard operator actions.