Reset first check conf, then reload conf & restart task
(conf *TaskConfig)
| 57 | |
| 58 | //Reset first check conf, then reload conf & restart task |
| 59 | func (task *QueueTask) Reset(conf *TaskConfig) error { |
| 60 | if conf.Interval <= 0 { |
| 61 | errmsg := "interval is wrong format => must bigger then zero" |
| 62 | task.taskService.Logger().Debug(fmt.Sprint("TaskInfo:Reset ", task, conf, "error", errmsg)) |
| 63 | return errors.New(errmsg) |
| 64 | } |
| 65 | |
| 66 | //restart task |
| 67 | task.Stop() |
| 68 | task.IsRun = conf.IsRun |
| 69 | if conf.TaskData != nil { |
| 70 | task.TaskData = conf.TaskData |
| 71 | } |
| 72 | if conf.Handler != nil { |
| 73 | task.handler = conf.Handler |
| 74 | } |
| 75 | task.Interval = conf.Interval |
| 76 | task.Start() |
| 77 | task.taskService.Logger().Debug(fmt.Sprint("TaskInfo:Reset ", task, conf, "success")) |
| 78 | return nil |
| 79 | } |
| 80 | |
| 81 | // NewQueueTask create new queue task |
| 82 | func NewQueueTask(taskID string, isRun bool, interval int64, handler TaskHandle, taskData interface{}, queueSize int64) (Task, error) { |