Skip to content

Commit

Permalink
fix: fix jitter
Browse files Browse the repository at this point in the history
  • Loading branch information
starudream committed Sep 7, 2024
1 parent a2385ec commit d7a0eb4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/cron/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ func Run() {
}
if c.Spec != "" {
err := cron.AddJob(c.Spec, k, func() {
jitter := gh.Ternary(c.Jitter > 0, time.Duration(float64(c.Jitter)*rand.Float64())*time.Second, time.Duration(0))
jitter := int(gh.Ternary(c.Jitter > 0, float64(c.Jitter)*rand.Float64(), 0))
if jitter > 0 {
slog.Debug("cron job %s jitter %d seconds", k, jitter)
time.Sleep(jitter)
time.Sleep(time.Duration(jitter) * time.Second)
}
v.Do()
})
Expand Down

0 comments on commit d7a0eb4

Please sign in to comment.