Compare commits

..

2 Commits

Author SHA1 Message Date
zhangdeman 65f753208a Merge branch 'master' of git.zhangdeman.cn:zhangdeman/task 2023-03-06 22:40:41 +08:00
zhangdeman a7b5da90c7 优化任务定义及返回值 2023-03-06 22:36:30 +08:00
3 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ type ITask interface {
Description() string
// GetRunID 获取任务ID
GetRunID() string
// Callback 任务执行的回调
// Callback 任务执行成功的回调
Callback(result *Result) error
// Execute 执行任务
Execute(ctx context.Context, cfg *Config) (map[string]interface{}, error)
+1
View File
@@ -37,6 +37,7 @@ type Result struct {
TaskRunID string // 任务运行ID
TaskDescription string // 任务描述
TaskConfig *Config // 任务配置
Async bool // 是否运行
Data map[string]interface{} // 任务结果数据
Err error // 异常信息, err == nil , 代表执行成功
}
+1
View File
@@ -109,6 +109,7 @@ func (d *dispatch) Run(ctx context.Context, cfg *Config) *Result {
TaskConfig: cfg,
Data: nil,
Err: nil,
Async: cfg.Async,
}
defer func() {
result.FinishTime = time.Now().UnixNano()