File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,8 @@ other instances checking to see if a new leader needs to be elected.
121
121
- [ ** Locker** ] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithDistributedLocker ) :
122
122
A locker can be used to lock each run of a job to a single instance of gocron.
123
123
Locker can be at job or scheduler, if it is defined both at job and scheduler then locker of job will take precedence.
124
+ - See Notes in the doc for [ Locker] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#Locker ) for
125
+ details and limitations of the locker design.
124
126
- Implementations: [ go-co-op lockers] ( https://github.com/go-co-op?q=-lock&type=all&language=&sort= )
125
127
(don't see what you need? request on slack to get a repo created to contribute it!)
126
128
Original file line number Diff line number Diff line change @@ -18,6 +18,21 @@ type Elector interface {
18
18
// locker implementation handles time splay between schedulers.
19
19
// The lock key passed is the job's name - which, if not set, defaults to the
20
20
// go function's name, e.g. "pkg.myJob" for func myJob() {} in pkg
21
+ //
22
+ // Notes: The locker and scheduler do not handle synchronization of run times across
23
+ // schedulers.
24
+ //
25
+ // 1. If you are using duration based jobs (DurationJob), you can utilize the JobOption
26
+ // WithStartAt to set a start time for the job to the nearest time rounded to your
27
+ // duration. For example, if you have a job that runs every 5 minutes, you can set
28
+ // the start time to the nearest 5 minute e.g. 12:05, 12:10.
29
+ //
30
+ // 2. For all jobs, the implementation is still vulnerable to clockskew between scheduler
31
+ // instances. This may result in a single scheduler instance running the majority of the
32
+ // jobs.
33
+ //
34
+ // For distributed jobs, consider utilizing the Elector option if these notes are not acceptable
35
+ // to your use case.
21
36
type Locker interface {
22
37
// Lock if an error is returned by lock, the job will not be scheduled.
23
38
Lock (ctx context.Context , key string ) (Lock , error )
You can’t perform that action at this time.
0 commit comments