This commit is contained in:
shoopea 2020-01-02 20:07:46 +08:00
parent 014bcb7873
commit 5aff9b0bd3
3 changed files with 22 additions and 22 deletions

2
def.go
View File

@ -319,7 +319,7 @@ type BotMsg struct {
type Job struct { type Job struct {
ID64 int64 ID64 int64
JobTypeID int32 JobTypeID64 int64
Trigger int64 Trigger int64
Timeout time.Time Timeout time.Time
UserID64 int64 UserID64 int64

6
job.go
View File

@ -154,7 +154,7 @@ func rescheduleJob(jobID64 int64, trigger int64, schedule time.Time) error {
func loadCurrentJobs() ([]Job, error) { func loadCurrentJobs() ([]Job, error) {
var ( var (
objId int64 objId int64
jobTypeId int32 jobTypeID64 int64
userID64 int64 userID64 int64
trigger int64 trigger int64
timeout time.Time timeout time.Time
@ -187,11 +187,11 @@ func loadCurrentJobs() ([]Job, error) {
} }
for rows.Next() { for rows.Next() {
err = rows.Scan(&objId, &jobTypeId, &trigger, &userID64, &payload, &timeout) err = rows.Scan(&objId, &jobTypeID64, &trigger, &userID64, &payload, &timeout)
logOnError(err, "loadCurrentJobs : scan query rows") logOnError(err, "loadCurrentJobs : scan query rows")
job := Job{ job := Job{
ID64: objId, ID64: objId,
JobTypeID: jobTypeId, JobTypeID64: jobTypeID64,
Trigger: trigger, Trigger: trigger,
UserID64: userID64, UserID64: userID64,
Payload: payload, Payload: payload,

View File

@ -548,7 +548,7 @@ func JobWorker(id int, jobs <-chan Job) {
for j := range jobs { for j := range jobs {
//log.Printf("JobWorker[%d] : Starting job %d (timeout : %s).\n", id, j.ID64, j.Timeout.Format(time.RFC3339)) //log.Printf("JobWorker[%d] : Starting job %d (timeout : %s).\n", id, j.ID64, j.Timeout.Format(time.RFC3339))
if time.Now().UTC().Before(j.Timeout) { if time.Now().UTC().Before(j.Timeout) {
switch j.JobTypeID { switch j.JobTypeID64 {
case cacheObjSubType[`job_rescan_msg`]: case cacheObjSubType[`job_rescan_msg`]:
jobRescan(j) jobRescan(j)
case cacheObjSubType[`job_set_done`]: case cacheObjSubType[`job_set_done`]:
@ -582,7 +582,7 @@ func JobWorker(id int, jobs <-chan Job) {
case cacheObjSubType[`job_get_hammer_time`]: case cacheObjSubType[`job_get_hammer_time`]:
jobGetHammerTime(j) jobGetHammerTime(j)
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.JobTypeID64)
} }
} else { } else {
log.Printf("JobWorker[%d] : Job %d timed out.\n", id, j.ID64) log.Printf("JobWorker[%d] : Job %d timed out.\n", id, j.ID64)