- FreeBatchStoreSkuInfo与FreeBatchStoreSkuSyncInfo添加任务名

This commit is contained in:
gazebo
2019-08-07 14:15:30 +08:00
parent cef5be3e06
commit 8768fe8236
7 changed files with 33 additions and 24 deletions

View File

@@ -130,9 +130,7 @@ func (task *ParallelTask) Run() {
if err != nil { // 出错
// globals.SugarLogger.Infof("ParallelTask.Run %s, subtask(job:%s, params:%s) result:%v, failed with error:%v", task.Name, utils.Format4Output(job, true), utils.Format4Output(task.params, true), result, err)
if task.IsContinueWhenError {
task.locker.Lock()
task.batchErrList = append(task.batchErrList, err)
task.locker.Unlock()
task.AddBatchErr(err)
} else {
chanRetVal = err
goto end

View File

@@ -44,9 +44,7 @@ func (task *SeqTask) Run() {
if err != nil {
// globals.SugarLogger.Infof("SeqTask.Run %s step:%d failed with error:%v", task.Name, i, err)
if task.IsContinueWhenError {
task.locker.Lock()
task.batchErrList = append(task.batchErrList, err)
task.locker.Unlock()
task.AddBatchErr(err)
} else {
taskErr = err
break

View File

@@ -3,6 +3,7 @@ package tasksch
import (
"encoding/json"
"fmt"
"strings"
"sync"
"time"
@@ -283,6 +284,14 @@ func (t *BaseTask) getResult() []interface{} {
return t.Result
}
func (t *BaseTask) AddBatchErr(err error) {
if err != nil {
t.locker.Lock()
defer t.locker.Unlock()
t.batchErrList = append(t.batchErrList, err)
}
}
// func (t *BaseTask) GetOriginalErr() error {
// t.locker.RLock()
// defer t.locker.RUnlock()
@@ -330,9 +339,11 @@ func (t *BaseTask) Error() (errMsg string) {
errMsg += "," + t.mainErr.Error()
} else {
errMsg += fmt.Sprintf("部分失败, 总共:%d, 成功:%d, 失败:%d, 详情如下:\n", t.TotalItemCount, t.FinishedItemCount, t.FailedItemCount)
for _, v := range t.batchErrList {
errMsg += fmt.Sprintf("%s,\n", v.Error())
strList := make([]string, len(t.batchErrList))
for k, v := range t.batchErrList {
strList[k] = v.Error()
}
errMsg += strings.Join(strList, ",\n")
}
t.locker.Lock()
t.Err = errMsg