From c1915321e1dced927f38ec6cdac2c5c14a0a30bc Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 1 Feb 2024 19:18:06 -0500 Subject: [PATCH] fix: if retry limit is reached pass the ErrRetryLimitReached error --- cron/cron.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cron/cron.go b/cron/cron.go index 948c044..e8669c7 100644 --- a/cron/cron.go +++ b/cron/cron.go @@ -2,6 +2,7 @@ package cron import ( "context" + "errors" "github.com/google/uuid" "go.uber.org/fx" "go.uber.org/zap" @@ -10,6 +11,10 @@ import ( "github.com/go-co-op/gocron/v2" ) +var ( + ErrRetryLimitReached = errors.New("Retry limit reached") +) + type CronService interface { Scheduler() gocron.Scheduler RegisterService(service CronableService) @@ -114,6 +119,7 @@ func (c *CronServiceDefault) RetryableTask(params RetryableTaskParams) CronJob { if params.Attempt >= params.Limit { c.logger.Error("Retryable task limit reached", zap.String("jobName", jobName), zap.String("jobID", jobID.String())) + params.Error(jobID, jobName, ErrRetryLimitReached) return }