update timed out jobs

This commit is contained in:
shoopea 2019-08-24 13:32:55 +08:00
parent bb14f6a1cf
commit 0d50ea9ed4
2 changed files with 31 additions and 26 deletions

10
job.go
View File

@ -770,35 +770,35 @@ func jobGDeposit(j Job) {
if res {
log.Printf("jobGDeposit : Sending res.\n")
clientSendCWMsgDelay(p.ChatID64, `📦Resources`, delay)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, 10*time.Second)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, (10+delay)*time.Second)
logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2
}
if alch {
log.Printf("jobGDeposit : Sending alch.\n")
clientSendCWMsgDelay(p.ChatID64, `Alchemy`, delay)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, 10*time.Second)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, (10+delay)*time.Second)
logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2
}
if misc {
log.Printf("jobGDeposit : Sending misc.\n")
clientSendCWMsgDelay(p.ChatID64, `🗃Misc`, delay)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, 10*time.Second)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, (10+delay)*time.Second)
logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2
}
if craft {
log.Printf("jobGDeposit : Sending craft.\n")
clientSendCWMsgDelay(p.ChatID64, `⚒Crafting`, delay)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, 10*time.Second)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, (10+delay)*time.Second)
logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2
}
if equip {
log.Printf("jobGDeposit : Sending equip.\n")
clientSendCWMsgDelay(p.ChatID64, `🏷Equipment`, delay)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, 10*time.Second)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, (10+delay)*time.Second)
logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2
}

View File

@ -514,6 +514,7 @@ func JobWorker(id int, jobs <-chan Job) {
// FIXME : discard timed out jobs
for j := range jobs {
//log.Printf("JobWorker[%d] : Starting job %d.\n", id, j.ID64)
if time.Now().UTC().Before(j.Timeout) {
switch j.JobTypeID {
case objSubTypeJobRescanMsg:
jobRescan(j)
@ -536,6 +537,10 @@ func JobWorker(id int, jobs <-chan Job) {
default:
log.Printf("jobWorker["+strconv.Itoa(id)+"] : No handler for job type #%d.\n", j.JobTypeID)
}
} else {
log.Printf("JobWorker[%d] : Job %d timed out.\n", id, j.ID64)
setJobDone(j.ID64)
}
}
log.Printf("jobWorker[" + strconv.Itoa(id) + "] : Closing.")
}