๐ go-scheduler - Awesome Go Library for Job Scheduler

Job scheduler supporting standard cron expressions, custom descriptors, intervals, and task dependencies
Detailed Description of go-scheduler
[!NOTE] This README was generated by SKILL, get the ZH version from here.
go-scheduler
Lightweight Go task scheduler with cron syntax, task dependency chains, and failure strategy control.
Table of Contents
Features
go get github.com/pardnchiu/go-schedulerยท Documentation
Cron Scheduling with Live Dispatch
Supports standard five-field cron expressions and preset descriptors like @every and @daily. A min-heap sorts trigger times so the next due task is woken with minimal overhead. Tasks can be added or removed dynamically while the scheduler is running, with no restart required.
Task Dependency Chains with Failure Strategies
Tasks can declare dependencies on other tasks, and the scheduler automatically blocks execution until prerequisites complete. Two failure strategies are provided: Skip ignores the failure and proceeds, while Stop aborts the entire dependency chain. Each dependency accepts an independent timeout to prevent a single stalled task from blocking the whole schedule.
Concurrency-Safe Execution with Panic Recovery
Each task runs in its own goroutine, with mutex and channel coordination ensuring consistent state. Panics are automatically recovered so one failing task never crashes the scheduler. Context-based timeouts trigger an onDelay callback, giving callers a hook for cleanup logic.
Architecture
graph TB
subgraph Scheduler
C[Cron Engine]
H[Min-Heap]
end
subgraph Dependencies
DM[Depend Manager]
W[Worker Pool]
end
C -->|schedule trigger| H
H -->|due task| C
C -->|has deps| DM
C -->|no deps| G[Goroutine Exec]
DM -->|check complete| W
W -->|deps satisfied| G
G -->|report result| DM
File Structure
go-scheduler/
โโโ instance.go # Scheduler creation, start, stop, and task execution
โโโ add.go # Task addition and argument parsing
โโโ remove.go # Task removal
โโโ task.go # Task listing and heap implementation
โโโ schedule.go # Cron expression and descriptor parsing
โโโ type.go # Type definitions and constants
โโโ depend.go # Dependency worker pool and task execution
โโโ dependManager.go # Dependency checking, waiting, and state updates
โโโ cron_test.go # Unit tests and benchmarks
โโโ go.mod
โโโ LICENSE
License
This project is licensed under the MIT LICENSE.
Author
้ฑๆฌๅน Pardn Chiu
Stars
ยฉ๏ธ 2025 ้ฑๆฌๅน Pardn Chiu