Skip to content

Commit

Permalink
🎨 update snowflake node generate
Browse files Browse the repository at this point in the history
  • Loading branch information
smally84 committed Dec 23, 2020
1 parent 8afb796 commit 303926b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/pkg/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ var Node *snowflake.Node
func init() {
var err error
rand.Seed(time.Now().UnixNano())
Node, err = snowflake.NewNode(int64(rand.Intn(1024)))
if DsfConfig.Tracker.NodeID > 0 {
Node, err = snowflake.NewNode(DsfConfig.Tracker.NodeID)
} else {
Node, err = snowflake.NewNode(int64(rand.Intn(1024)))
}

if err != nil {
panic("")
}
Expand Down

0 comments on commit 303926b

Please sign in to comment.