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 { if res {
log.Printf("jobGDeposit : Sending res.\n") log.Printf("jobGDeposit : Sending res.\n")
clientSendCWMsgDelay(p.ChatID64, `📦Resources`, delay) 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") logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2 delay = delay + 2
} }
if alch { if alch {
log.Printf("jobGDeposit : Sending alch.\n") log.Printf("jobGDeposit : Sending alch.\n")
clientSendCWMsgDelay(p.ChatID64, `Alchemy`, delay) 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") logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2 delay = delay + 2
} }
if misc { if misc {
log.Printf("jobGDeposit : Sending misc.\n") log.Printf("jobGDeposit : Sending misc.\n")
clientSendCWMsgDelay(p.ChatID64, `🗃Misc`, delay) 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") logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2 delay = delay + 2
} }
if craft { if craft {
log.Printf("jobGDeposit : Sending craft.\n") log.Printf("jobGDeposit : Sending craft.\n")
clientSendCWMsgDelay(p.ChatID64, `⚒Crafting`, delay) 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") logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2 delay = delay + 2
} }
if equip { if equip {
log.Printf("jobGDeposit : Sending equip.\n") log.Printf("jobGDeposit : Sending equip.\n")
clientSendCWMsgDelay(p.ChatID64, `🏷Equipment`, delay) 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") logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2 delay = delay + 2
} }

View File

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