Repository navigation
🚀 Notify Worker SDK v1.1.0
📢 Notify Worker SDK v1.1.0 is here! 🎉
This release brings a major enhancement by introducing startWorkerServer, a streamlined way to initialize workers for processing queued notifications. Now, setting up a worker server is simpler, cleaner, and more efficient than ever before!
📦 What's New in v1.1.0?
1️⃣ New Feature: startWorkerServer() 🚀
✅ Easier Worker Initialization → Quickly start a worker in a single function call.
✅ Supports Multi-Channel Notifiers → Register Firebase, Telegram, Email, Web Push, or custom notifiers with ease.
✅ Batch & Rate-Limiting Support → Automatically processes notifications efficiently.
✅ Completion & Drain Events → Now, workers can trigger custom actions when jobs complete or queues are fully drained.
2️⃣ Simplified Worker Setup with startWorkerServer()
Previously, users had to manually initialize a worker, configure Redis, and register notifiers. Now, it's as simple as:
📌 Before (Manual Worker Setup)
import Redis from "ioredis";
import { RedisClient, NotifierRegistry, TelegramNotifier, WorkerManager } from "notify-worker-sdk";
const redis = new Redis("redis://localhost:6379");
RedisClient.setInstance(redis);
NotifierRegistry.register("telegram", new TelegramNotifier({ botToken: process.env.BOT_TOKEN as string }));
new WorkerManager({ queueName: "notifications", concurrency: 20 });
console.log("Worker started.");✅ Now (Using startWorkerServer())
import Redis from "ioredis";
import { startWorkerServer } from "notify-worker-sdk";
const redis = new Redis("redis://localhost:6379");
startWorkerServer({
redisInstance: redis,
queueName: "notifications",
concurrency: 20,
notifiers: {
telegram: { botToken: process.env.BOT_TOKEN as string },
},
onComplete: async (job, stats) => {
console.log(`✅ Job ${job.id} completed. Stats:`, stats);
},
onDrained: async () => {
console.log("🔥 All jobs processed, queue is empty!");
},
resetStatsAfterCompletion: true, // Optionally reset stats after all jobs are done
});✅ One-liner Worker Initialization! 🚀
3️⃣ Enhancements & Optimizations
⚡ Added onComplete Hook → Run custom logic after each job completes.
⚡ Added onDrained Hook → Get notified when all jobs in the queue are finished.
⚡ Supports Auto Stats Reset → Automatically clear tracking stats after processing.
⚡ Improved Error Handling → More detailed logs and stability improvements.
4️⃣ How to Upgrade
If you're upgrading from an earlier version:
npm install queue-notifier@latestThen update your worker startup scripts to use the new startWorkerServer() function.
📚 Documentation
📖 Full documentation is available in the README.md.
🙌 Acknowledgments
A huge thank you to the community for feedback and contributions! 🎉
🔥 Excited for v1.1.0? Give us a ⭐ on GitHub. 🚀
📩 Found an issue? Report it on the GitHub Issues Page.
🚀 v1.1.0 is live! Now launching worker servers is easier than ever! 🎉
Happy coding! 💻🚀