Reset first check conf, then reload conf & restart task special, TaskID can not be reset special, if TaskData is nil, it can not be reset special, if Handler is nil, it can not be reset
(conf *TaskConfig)
| 40 | //special, if TaskData is nil, it can not be reset |
| 41 | //special, if Handler is nil, it can not be reset |
| 42 | func (task *CronTask) Reset(conf *TaskConfig) error { |
| 43 | expresslist := strings.Split(conf.Express, " ") |
| 44 | |
| 45 | //basic check |
| 46 | if conf.Express == "" { |
| 47 | errmsg := "express is empty" |
| 48 | task.taskService.Logger().Debug(fmt.Sprint("TaskInfo:Reset ", task, conf, "error", errmsg)) |
| 49 | return errors.New(errmsg) |
| 50 | } |
| 51 | if len(expresslist) != 6 { |
| 52 | errmsg := "express is wrong format => not 6 parts" |
| 53 | task.taskService.Logger().Debug(fmt.Sprint("TaskInfo:Reset ", task, conf, "error", errmsg)) |
| 54 | return errors.New("express is wrong format => not 6 parts") |
| 55 | } |
| 56 | |
| 57 | //restart task |
| 58 | task.Stop() |
| 59 | task.IsRun = conf.IsRun |
| 60 | if conf.TaskData != nil { |
| 61 | task.TaskData = conf.TaskData |
| 62 | } |
| 63 | if conf.Handler != nil { |
| 64 | task.handler = conf.Handler |
| 65 | } |
| 66 | task.DueTime = conf.DueTime |
| 67 | task.RawExpress = conf.Express |
| 68 | if task.TaskType == TaskType_Cron { |
| 69 | task.time_WeekDay = parseExpress(expresslist[5], ExpressType_WeekDay) |
| 70 | task.taskService.debugExpress(task.time_WeekDay) |
| 71 | task.time_Month = parseExpress(expresslist[4], ExpressType_Month) |
| 72 | task.taskService.debugExpress(task.time_Month) |
| 73 | task.time_Day = parseExpress(expresslist[3], ExpressType_Day) |
| 74 | task.taskService.debugExpress(task.time_Day) |
| 75 | task.time_Hour = parseExpress(expresslist[2], ExpressType_Hour) |
| 76 | task.taskService.debugExpress(task.time_Hour) |
| 77 | task.time_Minute = parseExpress(expresslist[1], ExpressType_Minute) |
| 78 | task.taskService.debugExpress(task.time_Minute) |
| 79 | task.time_Second = parseExpress(expresslist[0], ExpressType_Second) |
| 80 | task.taskService.debugExpress(task.time_Second) |
| 81 | } |
| 82 | task.Start() |
| 83 | task.taskService.Logger().Debug(fmt.Sprint("TaskInfo:Reset ", task, conf, "success")) |
| 84 | return nil |
| 85 | } |
| 86 | |
| 87 | //Start start task |
| 88 | func (task *CronTask) Start() { |
nothing calls this directly
no test coverage detected