How go-co-op/gocron works
gocron is a Go scheduling library. A caller creates jobs from task functions and schedule definitions, registers them with a scheduler, starts it, and later shuts it down. The scheduler tracks run times and dispatches ready jobs to an executor, which runs tasks while enforcing concurrency rules. The README documents duration, random, cron, calendar, and one-time schedules, plus events, metrics, logging, and distributed coordination. Source excerpts show core dispatch and integration points; unsampled implementations are represented only where documented.
Main entry points: executor.go Executor · scheduler.go Scheduler · job.go Schedule Definitions · distributed.go Elector & Lock APIs
Components 10
Job Scheduling
- Scheduler
scheduler.go - Schedule Definitions
job.go - Job & Task
job.go
Execution Runtime
- Executor
executor.go - Concurrency Controls
executor.go
Monitoring & Integrations
- Elector & Lock APIs
distributed.go - Job Metrics
monitor.go - Scheduler Events
scheduler_monitor.go - Logger
logger.go
Other components
- Library Caller
Connections 15
- Library Caller → Scheduler: creates and controls
README.md - Library Caller → Schedule Definitions: selects schedule
README.md - Library Caller → Job & Task: provides task
README.md - Scheduler → Schedule Definitions: configures job
scheduler.go - Scheduler → Executor: starts executor
scheduler.go - Scheduler → Executor: dispatches runs
README.md - Executor → Job & Task: runs task
README.md - Executor → Concurrency Controls: applies limits
executor.go - Executor → Elector & Lock APIs: checks leadership
executor.go - Executor → Elector & Lock APIs: acquires job lock
distributed.go - Executor → Job Metrics: records metrics
executor.go - Scheduler → Scheduler Events: notifies lifecycle
scheduler.go - Executor → Scheduler Events: reports job events
executor.go - Executor → Logger: writes logs
executor.go - Scheduler → Logger: writes logs
scheduler.go