smithery/ngxtm

NestJS Scheduling

Distributed cron jobs and locking patterns.

Installation

$ npx skills add smithery/ngxtm --skill nestjs-scheduling

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery/ngxtm · top by installs.

npx skills add smithery/ngxtm

Browse all from smithery/ngxtm

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Skill metadata

Parsed from SKILL.md frontmatter.

More metadata
labels
["nestjs","cron","scheduling","redis"]
triggers
{"files":["**\/*.service.ts"],"keywords":["\"@Cron","CronExpression","ScheduleModule\""]}

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 1,296 B
  • docs SUMMARY.md 68 B

History

  1. First recorded snapshot · 0 installs

SKILL.md

Task Scheduling & Jobs

Distributed Cron (Critical)

  • Problem: @Cron() runs on every instance. In K8s with 3 pods, your "Daily Report" runs 3 times.
  • Solution: Distributed Locking using Redis.

- Pattern: Using a decorator to wrap the cron method. - Logic: SET resourcename myrandom_value NX PX 30000 (Redis Atomic Set).

Cron Decorator Pattern

  • Implementation:

``typescript @Cron(CronExpression.EVERYMINUTE) @DistributedLock({ key: 'sendemails', ttl: 5000 }) async handleCron() { // Only runs if lock acquired } ``

  • Tools: Use nestjs-redlock or custom Redis wrapper via redlock library.

Job Robustness

  • Isolation: Never perform heavy processing inside the Cron handler.

- Pattern: Cron -> Push Job ID to Queue (BullMQ) -> Worker processes it. - Why: Cron schedulers can get blocked by the Event Loop; Workers are scalable.

  • Error Handling: Wrap ALL cron logic in try/catch. Uncaught exceptions in a Cron job can crash the entire Node process.