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

Function NewCronTask

crontask.go:112–134  ·  view source on GitHub ↗

NewCronTask create new cron task

(taskID string, isRun bool, express string, handler TaskHandle, taskData interface{})

Source from the content-addressed store, hash-verified

110
111// NewCronTask create new cron task
112func NewCronTask(taskID string, isRun bool, express string, handler TaskHandle, taskData interface{}) (Task, error) {
113 task := new(CronTask)
114 task.initCounters()
115 task.taskID = taskID
116 task.TaskType = TaskType_Cron
117 task.IsRun = isRun
118 task.handler = handler
119 task.RawExpress = express
120 task.TaskData = taskData
121 expressList := strings.Split(express, " ")
122 if len(expressList) != 6 {
123 return nil, errors.New("express is wrong format => not 6 parts")
124 }
125 task.time_WeekDay = parseExpress(expressList[5], ExpressType_WeekDay)
126 task.time_Month = parseExpress(expressList[4], ExpressType_Month)
127 task.time_Day = parseExpress(expressList[3], ExpressType_Day)
128 task.time_Hour = parseExpress(expressList[2], ExpressType_Hour)
129 task.time_Minute = parseExpress(expressList[1], ExpressType_Minute)
130 task.time_Second = parseExpress(expressList[0], ExpressType_Second)
131
132 task.State = TaskState_Init
133 return task, nil
134}
135
136//start cron task
137func startCronTask(task *CronTask) {

Callers 2

CreateCronTaskMethod · 0.85

Calls 2

parseExpressFunction · 0.85
initCountersMethod · 0.80

Tested by

no test coverage detected