add logid

This commit is contained in:
bryanqiu 2022-12-05 10:49:36 +08:00
parent f6c68dec7c
commit ac4c30b171

7
uid.go
View File

@ -43,7 +43,7 @@ type Range struct {
Length int // lenght of this range Length int // lenght of this range
} }
type rangeQueue struct { type rangeQueue struct {
deque.Deque[*Range] //deque.Deque[*Range]
} }
const ( const (
@ -78,7 +78,8 @@ func NewIdCreator(typ string, helper IdCreatorHelper) IdCreator {
// Step 3. backgroud task for generate range // Step 3. backgroud task for generate range
go func() { go func() {
for { for i := 0; ; i++ {
log.SetLogid(fmt.Sprintf("uidcreator%07d", i))
for prefix, queue := range idg.Ranges { for prefix, queue := range idg.Ranges {
var qlen = queue.Len() var qlen = queue.Len()
var timeoutMs = 1 * time.Millisecond var timeoutMs = 1 * time.Millisecond
@ -98,7 +99,7 @@ func NewIdCreator(typ string, helper IdCreatorHelper) IdCreator {
time.Sleep((-timeoutMs) * time.Millisecond) time.Sleep((-timeoutMs) * time.Millisecond)
} }
} }
time.Sleep(1000 * time.Millisecond) time.Sleep(3000 * time.Millisecond)
} }
}() }()