當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Job.RunAt方法代碼示例

本文整理匯總了Golang中github.com/Lupino/periodic/driver.Job.RunAt方法的典型用法代碼示例。如果您正苦於以下問題:Golang Job.RunAt方法的具體用法?Golang Job.RunAt怎麽用?Golang Job.RunAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/Lupino/periodic/driver.Job的用法示例。


在下文中一共展示了Job.RunAt方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: SubmitJob

func (sched *Sched) SubmitJob(grabItem GrabItem, job driver.Job) bool {
	defer sched.JobLocker.Unlock()
	sched.JobLocker.Lock()
	if job.Name == "" {
		sched.driver.Delete(job.Id)
		return true
	}
	if _, ok := sched.procQueue[job.Id]; ok {
		return true
	}

	if !grabItem.w.alive {
		return false
	}
	if err := grabItem.w.HandleDo(grabItem.msgId, job); err != nil {
		grabItem.w.alive = false
		return false
	}
	now := time.Now()
	current := int64(now.Unix())
	job.Status = driver.JOB_STATUS_PROC
	job.RunAt = current
	sched.driver.Save(&job)
	sched.IncrStatProc(job)
	sched.pushRevertPQ(job)
	sched.NotifyRevertTimer()
	sched.procQueue[job.Id] = job
	sched.grabQueue.Remove(grabItem)
	return true
}
開發者ID:4honor,項目名稱:periodic,代碼行數:30,代碼來源:sched.go

示例2: submitJob

func (sched *Sched) submitJob(item grabItem, job driver.Job) bool {
	defer sched.jobLocker.Unlock()
	sched.jobLocker.Lock()
	if job.Name == "" {
		sched.driver.Delete(job.ID)
		return true
	}
	if _, ok := sched.procQueue[job.ID]; ok {
		return true
	}

	if !item.w.alive {
		return false
	}
	if err := item.w.handleJobAssign(item.msgID, job); err != nil {
		item.w.alive = false
		return false
	}
	now := time.Now()
	current := int64(now.Unix())
	job.SetProc()
	job.RunAt = current
	sched.driver.Save(&job)
	sched.incrStatProc(job)
	sched.pushRevertPQ(job)
	sched.notifyRevertTimer()
	sched.procQueue[job.ID] = job
	sched.grabQueue.remove(item)
	return true
}
開發者ID:monsterwof,項目名稱:periodic,代碼行數:30,代碼來源:sched.go


注:本文中的github.com/Lupino/periodic/driver.Job.RunAt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。