实现task工厂

This commit is contained in:
2025-09-17 16:55:56 +08:00
parent 8b8c539e06
commit dde277c14d
7 changed files with 89 additions and 40 deletions

View File

@@ -1,5 +1,10 @@
package task
import (
"git.huangwc.com/pig/pig-farm-controller/internal/infra/logs"
"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
)
// Task 定义了所有可被调度器执行的任务必须实现的接口。
type Task interface {
// Execute 是任务的核心执行逻辑。
@@ -9,7 +14,7 @@ type Task interface {
Execute() error
// ParseParams 解析参数
ParseParams() error
ParseParams(logger *logs.Logger, claimedLog *models.TaskExecutionLog) error
// OnFailure 定义了当 Execute 方法返回错误时,需要执行的回滚或清理逻辑。
// log: 任务执行的上下文。