Closed zhangzitao closed 4 years ago
Hi,
What will node.Generate() return if it generated more than 4096 (such as 5000) in 1 millisecond?
Will the squeue number reset to 0? or block?
import ( "fmt" "github.com/bwmarrin/snowflake" ) func main() { node, _ := snowflake.NewNode(0) m := make(map[int64]bool) timeMap := make(map[int64]bool) for i := 0; i < 5000; i++ { id := node.Generate() timeMap[id.Time()] = true if _, ok := m[id.Int64()]; ok { fmt.Printf("wrong: same id %d", id) } m[id.Int64()] = true } fmt.Printf("%+v", timeMap) }
Thanks!
sorry, I found the source code
if n.step == 0 { for now <= n.time { now = time.Since(n.epoch).Nanoseconds() / 1000000 } }
Hi,
What will node.Generate() return if it generated more than 4096 (such as 5000) in 1 millisecond?
Will the squeue number reset to 0? or block?
Thanks!