diff --git a/pkg/cache/task.go b/pkg/cache/task.go index 9c85fed89..15839fd66 100644 --- a/pkg/cache/task.go +++ b/pkg/cache/task.go @@ -693,34 +693,3 @@ func (task *Task) RetryThenFailTask(errorMessage, actionReason string) { task.failWithEvent(errorMessage, actionReason) } } -func (task *Task) setRetryTimer(timeout time.Duration, currentState string, event RetryTaskEvent) { - log.Log(log.ShimContext).Debug("Task retry timer initiated", - zap.String("appID", task.applicationID), - zap.String("TaskID", task.taskID), - zap.String("state", task.sm.Current()), - zap.Duration("timeout", timeout)) - - task.retryTimer = time.AfterFunc(timeout, task.timeoutRetryTimer(currentState, event)) -} - -func (task *Task) timeoutRetryTimer(expectedState string, event RetryTaskEvent) func() { - return func() { - task.lock.Lock() - defer task.lock.Unlock() - if expectedState == task.sm.Current() { - dispatcher.Dispatch(event) - } - - } -} - -func (task *Task) RetryThenFailTask(errorMessage, actionReason string) { - if task.attempt < task.retryNum { - log.Log(log.ShimCacheTask).Info("task failed, task will retrying", zap.String("taskID", task.taskID), zap.Int("attempt", task.attempt), zap.Int("retryNum", task.retryNum), zap.Duration("retryTimeInterval", task.retryTimeInterval), zap.String("errorMessage", errorMessage)) - task.attempt++ - task.setRetryTimer(task.retryTimeInterval, task.sm.Current(), NewRetryTaskEvent(task.applicationID, task.taskID, "retrying task")) - } else { - log.Log(log.ShimCacheTask).Error("task failed ", zap.String("taskID", task.taskID), zap.String("errorMessage", errorMessage)) - task.failWithEvent(errorMessage, actionReason) - } -}