test
This commit is contained in:
parent
748bf5892b
commit
f94e710911
23
job.go
23
job.go
@ -65,6 +65,19 @@ func createJob(jobTypeID64 int64, priority int32, userID64 int64, trigger int64,
|
||||
return 0, err
|
||||
}
|
||||
|
||||
j := new(Job)
|
||||
|
||||
j.ID64 = objId
|
||||
j.JobTypeID64 = jobTypeID64
|
||||
j.Trigger = trigger
|
||||
j.Timeout = time.Unix(maxUnixTimestamp, 0).UTC()
|
||||
j.UserID64 = userID64
|
||||
j.Payload = payload
|
||||
|
||||
muxObjJob.Lock()
|
||||
cacheObjJob[objId] = *j
|
||||
muxObjJob.Unlock()
|
||||
|
||||
return objId, nil
|
||||
}
|
||||
|
||||
@ -99,12 +112,20 @@ func setJobTimeout(jobID64 int64, d time.Duration) error {
|
||||
}
|
||||
defer stmt.Close()
|
||||
|
||||
_, err = stmt.Exec(time.Now().UTC().Add(d), jobID64)
|
||||
t := time.Now().UTC().Add(d)
|
||||
|
||||
_, err = stmt.Exec(t, jobID64)
|
||||
logOnError(err, fmt.Sprintf("setJobTimeout, update obj_job(%d)", jobID64))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
muxObjJob.Lock()
|
||||
j := cacheObjJob[jobID64]
|
||||
j.Timeout = t
|
||||
cacheObjJob[jobID64] = j
|
||||
muxObjJob.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
2
obj.go
2
obj.go
@ -1026,7 +1026,7 @@ func loadObjJob() error {
|
||||
|
||||
muxObjJob.Lock()
|
||||
cacheObjJob = make(map[int64]Job)
|
||||
muxObjItem.Unlock()
|
||||
muxObjJob.Unlock()
|
||||
|
||||
jobs, err := db.Query(`SELECT o.id, o.obj_sub_type_id, oj.trigger_id, oj.timeout, oj.user_id, oj.payload FROM obj o, obj_job oj WHERE o.id = oj.obj_id;;`)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user