Skip to content

Commit

Permalink
Merge pull request #48 from kanmu/add_lock_time
Browse files Browse the repository at this point in the history
Add lock_time tostart_job log
  • Loading branch information
winebarrel authored Nov 13, 2024
2 parents d9d589f + 59b5603 commit 7d5be5e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func (w *Worker) Work() {

// WorkOne work on job
func (w *Worker) WorkOne() (didWork bool) {
startTime := time.Now()
j, err := w.c.LockJob(w.Queue)
if err != nil {
log.Printf("attempting to lock job: %v", err)
Expand All @@ -103,7 +104,7 @@ func (w *Worker) WorkOne() (didWork bool) {
if j == nil {
return // no job was available
}
log.Printf("event=start_job job_id=%d job_type=%s", j.ID, j.Type)
log.Printf("event=start_job job_id=%d job_type=%s lock_time=%d", j.ID, j.Type, time.Since(startTime).Milliseconds())
j.tx, err = j.c.pool.Begin()
if err != nil {
log.Printf("failed to create transaction: %v", err)
Expand Down

0 comments on commit 7d5be5e

Please sign in to comment.