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.
121121- [ ** Locker** ] ( https://pkg.go.dev/github.com/go-co-op/gocron/v2#WithDistributedLocker ) :
122122A locker can be used to lock each run of a job to a single instance of gocron.
123123Locker 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.
124126 - Implementations: [ go-co-op lockers] ( https://github.com/go-co-op?q=-lock&type=all&language=&sort= )
125127 (don't see what you need? request on slack to get a repo created to contribute it!)
126128
Original file line number Diff line number Diff line change @@ -18,6 +18,21 @@ type Elector interface {
1818// locker implementation handles time splay between schedulers.
1919// The lock key passed is the job's name - which, if not set, defaults to the
2020// 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.
2136type Locker interface {
2237 // Lock if an error is returned by lock, the job will not be scheduled.
2338 Lock (ctx context.Context , key string ) (Lock , error )
You can’t perform that action at this time.
0 commit comments