同步错误返回

This commit is contained in:
苏尹岚
2020-01-09 14:02:32 +08:00
parent 77e4fb078f
commit e6c59c4850
8 changed files with 176 additions and 198 deletions

View File

@@ -65,7 +65,7 @@ type ITask interface {
AddBatchErr(err error)
AddErrMsg(failedList ...interface{})
GetErrMsg() (failedList []interface{})
SetFinishHook(func(task ITask, ctx *jxcontext.Context))
SetFinishHook(func(task ITask))
json.Marshaler
}
@@ -131,7 +131,7 @@ type BaseTask struct {
ctx *jxcontext.Context
isGetResultCalled bool
FailedList []interface{}
finishHook func(task ITask, ctx *jxcontext.Context)
finishHook func(task ITask)
}
func (s TaskList) Len() int {
@@ -362,7 +362,7 @@ func (t *BaseTask) Error() (errMsg string) {
return errMsg
}
func (t *BaseTask) SetFinishHook(hook func(task ITask, ctx *jxcontext.Context)) {
func (t *BaseTask) SetFinishHook(hook func(task ITask)) {
t.locker.RLock()
defer t.locker.RUnlock()
t.finishHook = hook
@@ -450,7 +450,7 @@ func (t *BaseTask) run(taskHandler func()) {
}
close(t.finishChan)
if t.finishHook != nil {
t.finishHook(t, t.ctx)
t.finishHook(t)
} else {
SendMessage(t)
}