From 1d1be8330bc33bf64ceab65b4ce001b45be4e033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Wed, 14 Sep 2022 17:58:12 +0800 Subject: [PATCH] - update run_id --- const.go | 2 +- run.go | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/const.go b/const.go index 6625466..7a67420 100644 --- a/const.go +++ b/const.go @@ -1,6 +1,6 @@ package gojobs const ( - Version = "1.0.83" + Version = "1.0.84" SpecifyIpNull = "0.0.0.0" ) diff --git a/run.go b/run.go index 207e9fd..0b6ff3c 100644 --- a/run.go +++ b/run.go @@ -3,12 +3,19 @@ package gojobs import ( "context" "go.dtapp.net/gojobs/jobs_gorm_model" - "go.dtapp.net/gostring" "go.dtapp.net/gotime" + "go.dtapp.net/gotrace_id" ) // Run 运行 func (c *Client) Run(ctx context.Context, info jobs_gorm_model.Task, status int, result string) { + + runId := gotrace_id.GetTraceIdContext(ctx) + if runId == "" { + c.zapLog.WithTraceId(ctx).Sugar().Errorf("[gojobs.Run]:%s", "上下文没有跟踪编号") + return + } + // 请求函数记录 err := c.db.gormClient.Db.Create(&jobs_gorm_model.TaskLog{ TaskId: info.Id, @@ -23,7 +30,7 @@ func (c *Client) Run(ctx context.Context, info jobs_gorm_model.Task, status int, err = c.EditTask(c.db.gormClient.Db, info.Id). Select("run_id", "result", "next_run_time"). Updates(jobs_gorm_model.Task{ - RunId: gostring.GetUuId(), + RunId: runId, Result: result, NextRunTime: gotime.Current().AfterSeconds(info.Frequency).Time, }).Error @@ -40,7 +47,7 @@ func (c *Client) Run(ctx context.Context, info jobs_gorm_model.Task, status int, Updates(jobs_gorm_model.Task{ StatusDesc: "执行成功", Number: info.Number + 1, - RunId: gostring.GetUuId(), + RunId: runId, UpdatedIp: c.config.systemOutsideIp, Result: result, NextRunTime: gotime.Current().AfterSeconds(info.Frequency).Time, @@ -72,7 +79,7 @@ func (c *Client) Run(ctx context.Context, info jobs_gorm_model.Task, status int, Updates(jobs_gorm_model.Task{ StatusDesc: "执行失败", Number: info.Number + 1, - RunId: gostring.GetUuId(), + RunId: runId, UpdatedIp: c.config.systemOutsideIp, Result: result, NextRunTime: gotime.Current().AfterSeconds(info.Frequency).Time,