Registry / devops / sharded-interval-queue

sharded-interval-queue

JSON →
library2.0.0jsnpmunverified

Sharded Interval Queue v2.0.0 is a zero-dependency, persistent store sharded queue that runs async functions in timed intervals while preserving ordering across shards. It supports in-memory, LowDB, and Redis adapters for persistence and scaling. V2 introduces job limits to cap concurrent running jobs. Key differentiator: sharded design allows multiple queues to coordinate under a single name, with no recurring intervals or hooks—execution starts on job add. Decorator and thunk patterns are supported for wrapping async jobs. Suitable for rate-limited scheduling with ordering guarantees.

npm install sharded-interval-queue
INSTALL
IMPORT
SIG · SHARDED-INTERVAL-Q
S
sharded-interval-queue
devopsjavascriptv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ShardedIntervalQueue
import { ShardedIntervalQueue } from 'sharded-interval-queue'
const ShardedIntervalQueue = require('sharded-interval-queue')
ESM import is standard; CommonJS require also works but TypeScript may require esModuleInterop.
ShardedIntervalQueue
const { ShardedIntervalQueue } = require('sharded-interval-queue')
const ShardedIntervalQueue = require('sharded-interval-queue').default
CommonJS destructured import is correct; default export is not used.

Demonstrates queue creation, init, decorator and thunk job enqueuing, pausing/unpausing, and using job limit option.

import { ShardedIntervalQueue } from 'sharded-interval-queue'; async function main() { const queue = new ShardedIntervalQueue('MyQueue'); await queue.init(1000); // 1 second interval async function job(name) { return `Hello ${name}!`; } // Decorator pattern const wrappedJob = queue.decorator(job); const result1 = await wrappedJob('Alice'); console.log(result1); // Hello Alice! // Thunk pattern const result2 = await queue.add(() => job('Bob')); console.log(result2); // Hello Bob! await queue.pause(); // Restart by adding a job (auto-starts) or queue.start() await queue.unpause(); queue.start(); // With job limit (v2 feature) const limitedQueue = new ShardedIntervalQueue('LimitedQueue', { jobLimit: 5 }); await limitedQueue.init(500); limitedQueue.add(job('Charlie')); } main().catch(console.error);
Debug
Known issues
breakingIn v2, `incrementAsync` and `decrementAsync` are optional for custom storage adapters; previously required.
fix
Update custom adapters to optionally omit these methods or implement them if needed.
affects: >=2.0.0
gotchaQueue does not auto-restart after unpause; you must call start() or add a job to resume execution.
fix
After unpausing, call queue.start() or add a new job to resume.
affects: *
gotchaLowDB adapter requires setStorageLowDB() before init(), or the queue will use the default global store.
fix
Call queue.setStorageLowDB(db) before await queue.init(interval).
affects: *
deprecatedLowDB v1 adapter usage; newer LowDB v5+ has a different API.
fix
For LowDB v5, use lowdb with FileSync/FileAsync adapters compatible with this package.
affects: *
Errors
Common errors & fixes
Cannot find module 'lowdb/adapters/FileAsync'
LowDB v5+ changed adapter paths; FileAsync is no longer available.
fix
Use lowdb v1 or v2, or adapt custom storage instead.
queue.init is not a function
Queue not properly imported or instantiated; missing new keyword or wrong import.
fix
Ensure correct import: const { ShardedIntervalQueue } = require('sharded-interval-queue'); and use new ShardedIntervalQueue(name).
Cannot read property 'add' of undefined
Queue not initialized; init() not called or not awaited.
fix
Add await queue.init(interval) before using add().
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
sharded-interval-queue — npm install sharded-interval-queue · libregistry