25 lines
680 B
Go
25 lines
680 B
Go
package schedule
|
|
|
|
import (
|
|
"context"
|
|
"likedream-goframe/internal/framework/logger"
|
|
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
// StopTask 让任务队列停止执行某任务
|
|
//
|
|
// 注意,只有当任务处于等待执行、失败、成功和已排队状态时才能执行成功,否则会返回错误。
|
|
//
|
|
// 参数中,queue可为空,若queue为空则为default队列
|
|
func StopTask(ctx context.Context, queue, taskID string) {
|
|
if queue == "" {
|
|
queue = "default"
|
|
}
|
|
e := globalInspector.DeleteTask(queue, taskID)
|
|
if e != nil {
|
|
logger.Logger.Error("删除定时任务失败", zap.Error(e))
|
|
}
|
|
//utils.OkOrPanic(e, oops.WithContext(ctx).With("queue", queue, "taskID", taskID).Wrap)
|
|
}
|