fix: 完成商务迁移复核与接口优化并清理历史资料

This commit is contained in:
Yvan
2026-11-04 14:45:02 +08:00
parent 5a96be6a79
commit 297e80827d
176 changed files with 6803 additions and 6002 deletions
+32 -2
View File
@@ -211,7 +211,34 @@ func (e *TaskExecutor) runMethod(ctx context.Context, task *taskbiz.TimedTask) e
if e.methodOrphaned(task.ID) {
return errTaskOrphaned
}
runCtx, cancel := context.WithTimeout(ctx, 5*time.Minute)
options, err := taskbiz.MethodExecutionOptions(task.Params)
if err != nil {
return err
}
for attempt := 0; attempt <= options.MaxRetryTimes; attempt++ {
err = e.runMethodAttempt(ctx, task, method, options.Timeout)
if err == nil || ctx.Err() != nil || errors.Is(err, context.Canceled) || e.methodOrphaned(task.ID) {
return err
}
if attempt < options.MaxRetryTimes {
slog.WarnContext(ctx, "任务执行失败,准备重试", "task_id", task.ID, "method", task.MethodName, "attempt", attempt+1, "max_retry_times", options.MaxRetryTimes, "error", err)
timer := time.NewTimer(options.RetryInterval)
select {
case <-ctx.Done():
timer.Stop()
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
return errTaskTimeout
}
return ctx.Err()
case <-timer.C:
}
}
}
return err
}
func (e *TaskExecutor) runMethodAttempt(ctx context.Context, task *taskbiz.TimedTask, method platformtask.MethodFunc, timeout time.Duration) error {
runCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
done := make(chan error, 1)
go func() {
@@ -224,9 +251,12 @@ func (e *TaskExecutor) runMethod(ctx context.Context, task *taskbiz.TimedTask) e
}()
select {
case err := <-done:
if errors.Is(err, context.DeadlineExceeded) {
if errors.Is(err, context.DeadlineExceeded) || errors.Is(runCtx.Err(), context.DeadlineExceeded) {
return errTaskTimeout
}
if runCtx.Err() != nil {
return runCtx.Err()
}
return err
case <-runCtx.Done():
e.markMethodOrphan(task.ID, done)