fix: if retry limit is reached pass the ErrRetryLimitReached error
This commit is contained in:
parent
9825c904da
commit
c1915321e1
|
@ -2,6 +2,7 @@ package cron
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"go.uber.org/fx"
|
"go.uber.org/fx"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -10,6 +11,10 @@ import (
|
||||||
"github.com/go-co-op/gocron/v2"
|
"github.com/go-co-op/gocron/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrRetryLimitReached = errors.New("Retry limit reached")
|
||||||
|
)
|
||||||
|
|
||||||
type CronService interface {
|
type CronService interface {
|
||||||
Scheduler() gocron.Scheduler
|
Scheduler() gocron.Scheduler
|
||||||
RegisterService(service CronableService)
|
RegisterService(service CronableService)
|
||||||
|
@ -114,6 +119,7 @@ func (c *CronServiceDefault) RetryableTask(params RetryableTaskParams) CronJob {
|
||||||
|
|
||||||
if params.Attempt >= params.Limit {
|
if params.Attempt >= params.Limit {
|
||||||
c.logger.Error("Retryable task limit reached", zap.String("jobName", jobName), zap.String("jobID", jobID.String()))
|
c.logger.Error("Retryable task limit reached", zap.String("jobName", jobName), zap.String("jobID", jobID.String()))
|
||||||
|
params.Error(jobID, jobName, ErrRetryLimitReached)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue