nestjs-scheduling
БесплатноБез исполняемых скриптовНе проверенImplement distributed cron jobs with Redis-based locking and BullMQ offloading in NestJS. Use when adding @Cron scheduled tasks, preventing duplicate runs…
от HoangNguyen0403★ 598 звёзд на GitHubОб этом скилле
Task Scheduling & Jobs
Priority: P1 (HIGH)
Workflow: Add Scheduled Task
- Register ScheduleModule — Import
ScheduleModule.forRoot()in AppModule. - Create cron handler — Decorate service method with
@Cron(CronExpression.*). - Add distributed lock — Apply Redis lock decorator to prevent multi-pod duplication.
- Offload heavy work — Push job IDs to BullMQ; let workers process them.
- Wrap in try/catch — Uncaught exceptions in cron handlers crash entire Node process.
- Verify — Test with 2+ instances to confirm only one acquires lock.
Problem & Solution
- Problem:
@Cron()runs on every instance. In K8s with 3 pods, your "Daily Report" runs 3 times. - Solution: Distributed Locking using Redis.
- Pattern: Using decorator to wrap cron method.
- Logic:
SET resource_name my_random_value NX PX 30000(Redis Atomic Set).
Cron Decorator Pattern
- Implementation:
- Tools: Use
nestjs-redlockor custom Redis wrapper viaredlocklibrary.
Cron-to-Queue Offload
Job Robustness
- Isolation: Never perform heavy processing inside Cron handler.
- Pattern: Cron -> Push Job ID to Queue (BullMQ) -> Worker processes it.
- Why: Cron schedulers can get blocked by Event Loop; Workers scalable.
- Error Handling: Wrap ALL cron logic in
try/catch. Uncaught exceptions in Cron job can crash entire Node process.
Anti-Patterns
- No unguarded cron logic: Always wrap in
try/catch; uncaught exceptions crash entire Node process. - No direct cron processing: Push to BullMQ queue; workers scalable, cron handlers not.
- No bare @Cron in multi-pod: Use distributed locking (redlock) to prevent duplicate concurrent runs.
Установить nestjs-scheduling в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл nestjs-scheduling?
Implement distributed cron jobs with Redis-based locking and BullMQ offloading in NestJS. Use when adding @Cron scheduled tasks, preventing duplicate runs across pods, or delegating heavy work to queue workers.
Как установить скилл nestjs-scheduling?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл nestjs-scheduling запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic