Skip to content

Commit

Permalink
fix: cron scheduler duplicating logic
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Trost <[email protected]>
  • Loading branch information
galexrt committed Oct 28, 2024
1 parent 0b2e747 commit 7168288
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions pkg/croner/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,20 @@ func NewScheduler(p SchedulerParams) (*Scheduler, error) {
return cj, nil
}

ctx, cancel := context.WithCancel(ctxCancel)
s.jobs.Store(cj.Name, &jobWrapper{
ctx: ctx,
cancel: cancel,

schedule: cj.Schedule,
})
jw, ok := s.jobs.Load(cj.Name)
if !ok {
ctx, cancel := context.WithCancel(ctxCancel)
s.jobs.Store(cj.Name, &jobWrapper{
ctx: ctx,
cancel: cancel,

schedule: cj.Schedule,
})
} else {
if cj.Schedule != jw.schedule {
jw.schedule = cj.Schedule
}
}

return cj, nil
}),
Expand Down

0 comments on commit 7168288

Please sign in to comment.