periodic-workers

Automate recurring background jobs for API hosts with error isolation and graceful shutdown.

1|Updated Feb 28, 2024
One-click install
npx skills add https://github.com/Sparkymod/Template --skill periodic-workers
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: periodic-workers
Source: https://github.com/Sparkymod/Template/tree/main/.claude/skills/periodic-workers
Command: npx skills add https://github.com/Sparkymod/Template --skill periodic-workers

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill streamlines the process of adding recurring background jobs (like cleanup, retention, sync, notifications) to an API host, providing a robust solution to prevent common pitfalls associated with background job management.

Core Features & Use Cases

  • Periodic Worker Base: Utilizes PeriodicWorker for scheduling, error isolation, and graceful shutdown.
  • WorkerOptions Configuration: Offers configuration sections for customizing job behavior.
  • Registration and Alignment: Simplifies registration in WorkerRegistrationExtensions and ensures 5-appsettings alignment.
  • Domain: Focuses on background processing with an intermediate level of complexity.
  • Tags: Includes background-service, hosted-service, periodic, worker, retention.
  • Use Case: For instance, setting up a recurring cleanup job to delete old records in a database.

Quick Start

To schedule a cleanup job, configure WorkerOptions and register the ExpiredTokenCleanupWorker.

Frequently Asked Questions about periodic-workers

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up recurring background jobs for an API host?

To set up recurring background jobs for an API host, configure WorkerOptions to customize behavior and register workers using WorkerRegistrationExtensions. This automates scheduling and ensures appsettings alignment for your hosted services.

What is the best way to manage periodic cleanup tasks in a background service?

The best way to manage periodic cleanup tasks in a background service is using a PeriodicWorker base. It provides built-in error isolation and graceful shutdown, preventing common pitfalls during recurring database record retention jobs.

Can I isolate errors and ensure graceful shutdown for periodic tasks?

Yes, you can isolate errors and ensure graceful shutdown for periodic tasks. The PeriodicWorker base explicitly focuses on error isolation and graceful shutdown to prevent recurring background jobs from crashing your API host unexpectedly.

How do I configure WorkerOptions for custom retention and synchronization jobs?

You configure WorkerOptions for custom retention and synchronization jobs by defining configuration sections that customize job behavior. This is then aligned with your appsettings during the worker registration process.

When do I need a hosted service for background processing instead of standard API endpoints?

You need a hosted service for background processing when your API requires recurring retention, synchronization, or notification jobs. Periodic workers prevent these long-running tasks from blocking standard API endpoint request threads.