From ac4c30b1718c5d22d4acadd567a175fac01b606e Mon Sep 17 00:00:00 2001 From: bryanqiu Date: Mon, 5 Dec 2022 10:49:36 +0800 Subject: [PATCH] add logid --- uid.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/uid.go b/uid.go index db7c727..097edcd 100644 --- a/uid.go +++ b/uid.go @@ -43,7 +43,7 @@ type Range struct { Length int // lenght of this range } type rangeQueue struct { - deque.Deque[*Range] + //deque.Deque[*Range] } const ( @@ -78,7 +78,8 @@ func NewIdCreator(typ string, helper IdCreatorHelper) IdCreator { // Step 3. backgroud task for generate range go func() { - for { + for i := 0; ; i++ { + log.SetLogid(fmt.Sprintf("uidcreator%07d", i)) for prefix, queue := range idg.Ranges { var qlen = queue.Len() var timeoutMs = 1 * time.Millisecond @@ -98,7 +99,7 @@ func NewIdCreator(typ string, helper IdCreatorHelper) IdCreator { time.Sleep((-timeoutMs) * time.Millisecond) } } - time.Sleep(1000 * time.Millisecond) + time.Sleep(3000 * time.Millisecond) } }()