From 9330bb36bf286acd0984e801cdd2efd6d5c42712 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 1 Feb 2024 18:51:05 -0500 Subject: [PATCH] fix: fix after and error functions --- cron/cron.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cron/cron.go b/cron/cron.go index 5bffc55..948c044 100644 --- a/cron/cron.go +++ b/cron/cron.go @@ -101,14 +101,12 @@ func (c *CronServiceDefault) RetryableTask(params RetryableTaskParams) CronJob { task := gocron.NewTask(params.Function, params.Args...) - afterFunc := params.After - if afterFunc == nil { - afterFunc = func(jobID uuid.UUID, jobName string) {} + if params.After == nil { + params.After = func(jobID uuid.UUID, jobName string) {} } - errorFunc := params.Error - if errorFunc == nil { - errorFunc = func(jobID uuid.UUID, jobName string, err error) {} + if params.Error == nil { + params.Error = func(jobID uuid.UUID, jobName string, err error) {} } listeners := gocron.WithEventListeners(gocron.AfterJobRunsWithError(func(jobID uuid.UUID, jobName string, err error) {