MCPcopy Create free account
hub / github.com/devfeel/dottask / Reset

Method Reset

looptask.go:35–61  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

33//special, if TaskData is nil, it can not be reset
34//special, if Handler is nil, it can not be reset
35func (task *LoopTask) Reset(conf *TaskConfig) error {
36 if conf.DueTime < 0 {
37 errmsg := "DueTime is wrong format => must bigger or equal then zero"
38 task.taskService.Logger().Debug(fmt.Sprint("TaskInfo:Reset ", task, conf, "error", errmsg))
39 return errors.New(errmsg)
40 }
41
42 if conf.Interval <= 0 {
43 errmsg := "interval is wrong format => must bigger then zero"
44 task.taskService.Logger().Debug(fmt.Sprint("TaskInfo:Reset ", task, conf, "error", errmsg))
45 return errors.New(errmsg)
46 }
47 //restart task
48 task.Stop()
49 task.IsRun = conf.IsRun
50 if conf.TaskData != nil {
51 task.TaskData = conf.TaskData
52 }
53 if conf.Handler != nil {
54 task.handler = conf.Handler
55 }
56 task.DueTime = conf.DueTime
57 task.Interval = conf.Interval
58 task.Start()
59 task.taskService.Logger().Debug(fmt.Sprint("TaskInfo:Reset ", task, conf, "success"))
60 return nil
61}
62
63//Start start task
64func (task *LoopTask) Start() {

Callers

nothing calls this directly

Calls 4

StartMethod · 0.95
LoggerMethod · 0.80
DebugMethod · 0.65
StopMethod · 0.65

Tested by

no test coverage detected