本文整理匯總了Golang中github.com/Lupino/periodic/driver.Job.Func方法的典型用法代碼示例。如果您正苦於以下問題:Golang Job.Func方法的具體用法?Golang Job.Func怎麽用?Golang Job.Func使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Lupino/periodic/driver.Job
的用法示例。
在下文中一共展示了Job.Func方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: handleSubmitJob
func (c *httpClient) handleSubmitJob(req *http.Request) {
var job driver.Job
var e error
var sched = c.sched
defer sched.jobLocker.Unlock()
sched.jobLocker.Lock()
url := req.URL.String()
funcName := url[1:]
if funcName == "" {
funcName = req.FormValue("func")
}
job.Name = req.FormValue("name")
job.Func = funcName
job.Args = req.FormValue("args")
job.Timeout, _ = strconv.ParseInt(req.FormValue("timeout"), 10, 64)
job.SchedAt, _ = strconv.ParseInt(req.FormValue("sched_at"), 10, 64)
if job.Name == "" || job.Func == "" {
c.sendErrResponse(errors.New("job name or func is required"))
return
}
isNew := true
changed := false
job.SetReady()
oldJob, e := sched.driver.GetOne(job.Func, job.Name)
if e == nil && oldJob.ID > 0 {
job.ID = oldJob.ID
if job.IsProc() {
sched.decrStatProc(oldJob)
sched.removeRevertPQ(job)
changed = true
}
isNew = false
}
e = sched.driver.Save(&job)
if e != nil {
c.sendErrResponse(e)
return
}
if isNew {
sched.incrStatJob(job)
}
if isNew || changed {
sched.pushJobPQ(job)
}
sched.notifyJobTimer()
c.sendResponse("200 OK", []byte("{\"msg\": \""+protocol.SUCCESS.String()+"\"}"))
return
}