What problem does it solve?
It removes the repetitive setup work of building long-running background workers by providing a consistent lifecycle contract, test scaffolding, and configuration wiring in a single-binary Go project.
Core Features & Use Cases
- Worker scaffolding with lifecycle contract: Generates a worker implementation with
Start(ctx) that blocks until context cancellation and a Stop(ctx) hook for graceful shutdown cleanup.
- Scheduled (cron) workers: Creates cron-based workers using a standard cron expression and ensures the scheduler is started and stopped inside
Start.
- Dependency wiring and project integration: Adds the worker to
forge.yaml and instructs you to run generation so wiring is handled by pkg/app/bootstrap.go.
- Testing support: Generates a basic lifecycle test and provides patterns for verifying message processing using mock dependencies.
Quick Start
Add a cron-scheduled worker named cleanup by running the command: forge add worker cleanup --kind cron --schedule "0 */6 * * *".