@@ -8,15 +8,6 @@ gocron is a job scheduling package which lets you run Go functions at pre-determ
8
8
If you want to chat, you can find us on Slack at
9
9
[ <img src =" https://img.shields.io/badge/gophers-gocron-brightgreen?logo=slack " >] ( https://gophers.slack.com/archives/CQ7T0T1FW )
10
10
11
- ## Concepts
12
-
13
- - ** Job** : The encapsulates a "task", which is made up of a go func and any function parameters, and then
14
- provides the scheduler with the time the job should be scheduled to run.
15
- - ** Executor** : The executor, calls the "task" function and manages the complexities of different job
16
- execution timing (e.g. singletons that shouldn't overrun each other, limiting the max number of jobs running)
17
- - ** Scheduler** : The scheduler keeps track of all the jobs and sends each job to the executor when
18
- it is ready to be run.
19
-
20
11
## Quick Start
21
12
22
13
```
@@ -70,6 +61,16 @@ func main() {
70
61
}
71
62
```
72
63
64
+ ## Concepts
65
+
66
+ - ** Job** : The job encapsulates a "task", which is made up of a go function and any function parameters. The Job then
67
+ provides the scheduler with the time the job should next be scheduled to run.
68
+ - ** Scheduler** : The scheduler keeps track of all the jobs and sends each job to the executor when
69
+ it is ready to be run.
70
+ - ** Executor** : The executor calls the job's task and manages the complexities of different job
71
+ execution timing requirements (e.g. singletons that shouldn't overrun each other, limiting the max number of jobs running)
72
+
73
+
73
74
## Features
74
75
75
76
- ** Job types** : Jobs can be run at various intervals.
@@ -85,14 +86,15 @@ func main() {
85
86
Jobs can be run every x weeks on specific days of the week and at specific times.
86
87
- [ ** Monthly** ] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#MonthlyJob ) :
87
88
Jobs can be run every x months on specific days of the month and at specific times.
88
- - ** Limited Concurrency** : Jobs can be limited individually or across the entire scheduler.
89
+ - ** Concurrency Limits ** : Jobs can be limited individually or across the entire scheduler.
89
90
- [ ** Per job limiting with singleton mode** ] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithSingletonMode ) :
90
91
Jobs can be limited to a single concurrent execution that either reschedules (skips overlapping executions)
91
92
or queues (waits for the previous execution to finish).
92
93
- [ ** Per scheduler limiting with limit mode** ] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithLimitConcurrentJobs ) :
93
94
Jobs can be limited to a certain number of concurrent executions across the entire scheduler
94
95
using either reschedule (skip when the limit is met) or queue (jobs are added to a queue to
95
96
wait for the limit to be available).
97
+ - ** Note:** A scheduler limit and a job limit can both be enabled.
96
98
- ** Distributed instances of gocron** : Multiple instances of gocron can be run.
97
99
- [ ** Elector** ] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithDistributedElector ) :
98
100
An elector can be used to elect a single instance of gocron to run as the primary with the
@@ -103,31 +105,33 @@ func main() {
103
105
- Implementations: [ go-co-op lockers] ( https://github.com/go-co-op?q=-lock&type=all&language=&sort= )
104
106
- ** Events** : Job events can trigger actions.
105
107
- [ ** Listeners** ] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithEventListeners ) :
106
- [ Event listeners] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#EventListener )
107
- can be added to a job or all jobs in the
108
+ Can be added to a job, with [ event listeners] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#EventListener ) ,
109
+ or all jobs across the
108
110
[ scheduler] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithGlobalJobOptions )
109
111
to listen for job events and trigger actions.
110
- - ** Options** : Many job and scheduler options are available
112
+ - ** Options** : Many job and scheduler options are available.
111
113
- [ ** Job options** ] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#JobOption ) :
112
114
Job options can be set when creating a job using ` NewJob ` .
113
115
- [ ** Global job options** ] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithGlobalJobOptions ) :
114
- Global job options can be set when creating a scheduler using ` NewScheduler ` .
116
+ Global job options can be set when creating a scheduler using ` NewScheduler `
117
+ and the ` WithGlobalJobOptions ` option.
115
118
- [ ** Scheduler options** ] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#SchedulerOption ) :
116
119
Scheduler options can be set when creating a scheduler using ` NewScheduler ` .
117
120
- ** Logging** : Logs can be enabled.
118
121
- [ Logger] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#Logger ) :
119
122
The Logger interface can be implemented with your desired logging library.
120
123
The provided NewLogger uses the standard library's log package.
121
- - ** Mocking ** : The gocron library is set up to enable testing.
124
+ - ** Testing ** : The gocron library is set up to enable testing.
122
125
- Mocks are provided in [ the mock package] ( mocks ) using [ gomock] ( https://github.com/uber-go/mock ) .
123
126
- Time can be mocked by passing in a [ FakeClock] ( https://pkg.go.dev/github.com/jonboulle/clockwork#FakeClock )
124
127
to [ WithClock] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithClock ) -
125
- see the example on WithClock in the go-docs .
128
+ see the [ example on WithClock] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#example-WithClock ) .
126
129
127
130
## Supporters
128
131
129
- [ Jetbrains] ( https://www.jetbrains.com/?from=gocron ) supports this project with Intellij licenses.
130
- We appreciate their support for free and open source software!
132
+ We appreciate the support for free and open source software!
133
+
134
+ - [ Jetbrains] ( https://www.jetbrains.com/?from=gocron ) supports this project with Intellij licenses.
131
135
132
136
## Star History
133
137
0 commit comments