๐Ÿ“š go-scheduler - Awesome Go Library for Job Scheduler

Go Gopher mascot for go-scheduler

Job scheduler supporting standard cron expressions, custom descriptors, intervals, and task dependencies

๐Ÿท๏ธ Job Scheduler
๐Ÿ“‚ Job Scheduler
โญ 0 stars
View on GitHub ๐Ÿ”—

Detailed Description of go-scheduler

[!NOTE] This README was generated by SKILL, get the ZH version from here.

go-scheduler

pkg card codecov license version

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

Star


ยฉ๏ธ 2025 ้‚ฑๆ•ฌๅนƒ Pardn Chiu