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

12
def.go
View File

@ -318,12 +318,12 @@ type BotMsg struct {
}
type Job struct {
ID64 int64
JobTypeID int32
Trigger int64
Timeout time.Time
UserID64 int64
Payload []byte
ID64 int64
JobTypeID64 int64
Trigger int64
Timeout time.Time
UserID64 int64
Payload []byte
}
type JobPayloadGetHammerTime struct {

28
job.go
View File

@ -153,13 +153,13 @@ func rescheduleJob(jobID64 int64, trigger int64, schedule time.Time) error {
func loadCurrentJobs() ([]Job, error) {
var (
objId int64
jobTypeId int32
userID64 int64
trigger int64
timeout time.Time
payload []byte
jobs []Job
objId int64
jobTypeID64 int64
userID64 int64
trigger int64
timeout time.Time
payload []byte
jobs []Job
)
t := time.Now().UTC()
@ -187,15 +187,15 @@ func loadCurrentJobs() ([]Job, error) {
}
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")
job := Job{
ID64: objId,
JobTypeID: jobTypeId,
Trigger: trigger,
UserID64: userID64,
Payload: payload,
Timeout: timeout,
ID64: objId,
JobTypeID64: jobTypeID64,
Trigger: trigger,
UserID64: userID64,
Payload: payload,
Timeout: timeout,
}
jobs = append(jobs, job)
}

View File

@ -548,7 +548,7 @@ func JobWorker(id int, jobs <-chan Job) {
for j := range jobs {
//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) {
switch j.JobTypeID {
switch j.JobTypeID64 {
case cacheObjSubType[`job_rescan_msg`]:
jobRescan(j)
case cacheObjSubType[`job_set_done`]:
@ -582,7 +582,7 @@ func JobWorker(id int, jobs <-chan Job) {
case cacheObjSubType[`job_get_hammer_time`]:
jobGetHammerTime(j)
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 {
log.Printf("JobWorker[%d] : Job %d timed out.\n", id, j.ID64)