- when IsContinueWhenError is true, if partial failed, mark the whole task as failed.
This commit is contained in:
@@ -3,6 +3,7 @@ package tasksch
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -77,14 +78,13 @@ type BaseTask struct {
|
||||
|
||||
Result []interface{} `json:"result"`
|
||||
Children TaskList `json:"children"`
|
||||
Err error `json:"err"`
|
||||
|
||||
Err error `json:"err"`
|
||||
DetailErrList []error `json:"detailErrList"`
|
||||
|
||||
finishChan chan int
|
||||
C <-chan int `json:"-"`
|
||||
params []interface{}
|
||||
quitChan chan int
|
||||
detailErrMsgList []string `json:"-"`
|
||||
finishChan chan int
|
||||
C <-chan int `json:"-"`
|
||||
params []interface{}
|
||||
quitChan chan int
|
||||
|
||||
locker sync.RWMutex
|
||||
parent ITask
|
||||
@@ -139,9 +139,6 @@ func (t *BaseTask) GetResult(duration time.Duration) (retVal []interface{}, err
|
||||
select {
|
||||
case <-t.finishChan:
|
||||
timer.Stop()
|
||||
t.locker.RLock()
|
||||
defer t.locker.RUnlock()
|
||||
|
||||
return t.Result, t.Err
|
||||
case <-timer.C:
|
||||
}
|
||||
@@ -263,6 +260,7 @@ func (t *BaseTask) run(taskHandler func()) {
|
||||
globals.SugarLogger.Infof("BaseTask run, failed with error:%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
close(t.finishChan)
|
||||
})
|
||||
}
|
||||
@@ -288,3 +286,10 @@ func (t *BaseTask) setStatus(status int) {
|
||||
|
||||
t.Status = status
|
||||
}
|
||||
|
||||
func (t *BaseTask) buildTaskErrFromDetail() (err error) {
|
||||
if len(t.detailErrMsgList) > 0 {
|
||||
return NewTaskError(fmt.Errorf("设置了错误继续标志,部分操作失败,总任务数:%d,失败数:%d,以下为详情:\n%s", t.TotalItemCount, t.FailedItemCount, strings.Join(t.detailErrMsgList, "\n")))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user