fix: if retry limit is reached pass the ErrRetryLimitReached error

This commit is contained in:
Derrick Hammer 2024-02-01 19:18:06 -05:00
parent 9825c904da
commit c1915321e1
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 0 deletions

View File

@ -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
}