From fa1f3b4283ba447fbe06a600fe271d49481f0ade Mon Sep 17 00:00:00 2001 From: Yihang Wang Date: Thu, 11 Apr 2024 19:57:44 +0800 Subject: [PATCH] fix: add missing task id --- task.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/task.go b/task.go index 6ad9657..1e4d896 100644 --- a/task.go +++ b/task.go @@ -1,5 +1,7 @@ package gojob +import "github.com/google/uuid" + // Task is an interface that defines a task type Task interface { // Do starts the task, returns error if failed @@ -10,6 +12,7 @@ type Task interface { type BasicTask struct { Index int64 `json:"index"` + RunID string `json:"run_id"` ID string `json:"id"` StartedAt int64 `json:"started_at"` FinishedAt int64 `json:"finished_at"` @@ -18,10 +21,11 @@ type BasicTask struct { Error string `json:"error"` } -func NewBasicTask(index int64, id string, task Task) *BasicTask { +func NewBasicTask(index int64, runID string, task Task) *BasicTask { return &BasicTask{ Index: index, - ID: id, + RunID: runID, + ID: uuid.New().String(), StartedAt: 0, FinishedAt: 0, NumTries: 0,