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


Golang Job.IsProc方法代碼示例

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


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

示例1: handleRemoveJob

func (c *client) handleRemoveJob(msgID, payload []byte) (err error) {
	var job driver.Job
	var e error
	var conn = c.conn
	var sched = c.sched
	defer sched.jobLocker.Unlock()
	sched.jobLocker.Lock()
	job, e = driver.NewJob(payload)
	if e != nil {
		err = conn.Send([]byte(e.Error()))
		return
	}
	job, e = sched.driver.GetOne(job.Func, job.Name)
	if e == nil && job.ID > 0 {
		if _, ok := sched.procQueue[job.ID]; ok {
			delete(sched.procQueue, job.ID)
		}
		sched.driver.Delete(job.ID)
		sched.decrStatJob(job)
		if job.IsProc() {
			sched.decrStatProc(job)
			sched.removeRevertPQ(job)
		}
		sched.notifyJobTimer()
	}

	if e != nil {
		err = conn.Send([]byte(e.Error()))
	} else {
		err = c.handleCommand(msgID, protocol.SUCCESS)
	}
	return
}
開發者ID:monsterwof,項目名稱:periodic,代碼行數:33,代碼來源:client.go

示例2: handleRemoveJob

func (c *httpClient) handleRemoveJob(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")
	}
	name := req.FormValue("name")
	job, e = sched.driver.GetOne(funcName, name)
	if e == nil && job.ID > 0 {
		if _, ok := sched.procQueue[job.ID]; ok {
			delete(sched.procQueue, job.ID)
		}
		sched.driver.Delete(job.ID)
		sched.decrStatJob(job)
		if job.IsProc() {
			sched.decrStatProc(job)
			sched.removeRevertPQ(job)
		}
		sched.notifyJobTimer()
	}

	if e != nil {
		c.sendErrResponse(e)
	} else {
		c.sendResponse("200 OK", []byte("{\"msg\": \""+protocol.SUCCESS.String()+"\"}"))
	}
}
開發者ID:monsterwof,項目名稱:periodic,代碼行數:32,代碼來源:http.go

示例3: removeRevertPQ

func (sched *Sched) removeRevertPQ(job driver.Job) {
	defer sched.PQLocker.Unlock()
	sched.PQLocker.Lock()
	if job.IsProc() && job.Timeout > 0 {
		for _, item := range sched.revertPQ {
			if item.Value == job.ID {
				heap.Remove(&sched.revertPQ, item.Index)
				break
			}
		}
	}
}
開發者ID:monsterwof,項目名稱:periodic,代碼行數:12,代碼來源:sched.go

示例4: 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
}
開發者ID:monsterwof,項目名稱:periodic,代碼行數:51,代碼來源:http.go

示例5: pushRevertPQ

func (sched *Sched) pushRevertPQ(job driver.Job) {
	defer sched.PQLocker.Unlock()
	sched.PQLocker.Lock()
	if job.IsProc() && job.Timeout > 0 {
		runAt := job.RunAt
		if runAt == 0 {
			runAt = job.SchedAt
		}
		item := &queue.Item{
			Value:    job.ID,
			Priority: runAt + job.Timeout,
		}
		heap.Push(&sched.revertPQ, item)
	}
}
開發者ID:monsterwof,項目名稱:periodic,代碼行數:15,代碼來源:sched.go

示例6: decrStatProc

func (sched *Sched) decrStatProc(job driver.Job) {
	stat := sched.getFuncStat(job.Func)
	if job.IsProc() {
		stat.Processing.Decr()
	}
}
開發者ID:monsterwof,項目名稱:periodic,代碼行數:6,代碼來源:sched.go


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