MCPcopy Create free account
hub / github.com/DoNewsCode/core / DelayIfOverlap

Function DelayIfOverlap

cron/options.go:114–126  ·  view source on GitHub ↗

DelayIfOverlap returns a new JobDescriptor that will delay the job if it overlaps with another job.

()

Source from the content-addressed store, hash-verified

112
113// DelayIfOverlap returns a new JobDescriptor that will delay the job if it overlaps with another job.
114func DelayIfOverlap() JobOption {
115 ch := make(chan struct{}, 1)
116 return func(descriptor *JobDescriptor) {
117 innerRun := descriptor.Run
118 descriptor.Run = func(ctx context.Context) error {
119 ch <- struct{}{}
120 defer func() {
121 <-ch
122 }()
123 return innerRun(ctx)
124 }
125 }
126}
127
128// TimeoutIfOverlap returns a new JobDescriptor that will cancel the job's context if the next schedule is due.
129func TimeoutIfOverlap() JobOption {

Callers 1

TestJobOptionFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestJobOptionFunction · 0.68