Commit b29f7eb7 authored by Kyle Clarke's avatar Kyle Clarke 💬

Safer auto purge logic to ensure no leaky goroutines by calling stop always.

parent 2a79a1cf
Pipeline #4941006 passed with stage
in 1 minute and 23 seconds
......@@ -150,11 +150,12 @@ func (s *schedule) Run(j *Job) (JobID, error) {
// AutoPurge will setup a ticker to purge completed jobs based on this schedules
// PurgeAfter config value. Passing in a zero duration will stop the ticker.
func (s *schedule) AutoPurge(pollEvery time.Duration) {
if pollEvery.Nanoseconds() == 0 {
if nil != s.purgeTicker {
s.purgeTicker.Stop()
}
} else {
// Always call stop on any AutoPurge call to ensure no goroutine leaks.
if nil != s.purgeTicker {
s.purgeTicker.Stop()
}
if 0 != pollEvery.Nanoseconds() {
s.purgeTicker = time.NewTicker(pollEvery)
go func(s *schedule) {
for range s.purgeTicker.C {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment