Skip to content

Notify Adapters

Notify adapters handle pub/sub notifications for efficient job scheduling. When a job is created, workers are notified immediately instead of polling. This reduces latency from seconds to milliseconds.

Package: @queuert/redis

Recommended for production. Uses Redis pub/sub for broadcasting job notifications to workers. Includes a hint-based optimization using Lua scripts for atomic decrement, preventing thundering herd when many workers are idle — only as many workers as there are new jobs will query the database.

Terminal window
npm install @queuert/redis
ClientExample
node-redisnotify-redis-redis
ioredisnotify-redis-ioredis
node-redis clusternotify-redis-cluster-node-redis
ioredis clusternotify-redis-cluster-ioredis

A Notify Provider bridges your pub/sub client (Redis, NATS, PostgreSQL, etc.) with the notify adapter. You implement an interface for publishing messages and subscribing to channels:

  • publish — Sends a message to a named channel.
  • subscribe — Listens on a channel and invokes a callback when messages arrive. Returns a dispose function to unsubscribe.

The provider maintains a dedicated connection for subscriptions and acquires/releases connections for publish operations automatically. Each example linked above demonstrates a complete Notify Provider implementation for its corresponding client.

You’re not limited to the clients listed here — you can write a provider for any pub/sub client that supports the same semantics, or implement the NotifyAdapter interface from scratch for an entirely different message broker. See Custom Adapters for a walkthrough.

Queuert ships a conformance runner that exercises the 18-case notify adapter suite against any provider you build. Embed it in a single test() block from your test framework to validate correctness:

import { runNotifyAdapterConformance } from "queuert/conformance";
test("my provider passes notify adapter conformance", async () => {
await runNotifyAdapterConformance(async () => ({
notifyAdapter,
dispose: async () => { /* close connections */ },
}));
}, 60_000);

Every example’s src/provider.spec.ts is a working template. See the Custom Adapters guide for a full walkthrough and the Conformance reference for the complete API.