GetNode returns the snowflake node, initializing it once. If initialization fails, it will fatal the program.
()
| 86 | // GetNode returns the snowflake node, initializing it once. |
| 87 | // If initialization fails, it will fatal the program. |
| 88 | func (sm *SnowflakeManager) GetNode() *snowflake.Node { |
| 89 | sm.once.Do(func() { |
| 90 | var err error |
| 91 | sm.node, err = snowflake.NewNode(sm.nodeNum) |
| 92 | if err != nil { |
| 93 | utils.GetLogger().Printf("Failed to initialize snowflake node with nodeNum=%d: %v", sm.nodeNum, err) |
| 94 | panic(err) |
| 95 | } |
| 96 | }) |
| 97 | return sm.node |
| 98 | } |
| 99 | |
| 100 | // open returns a newly initialized DB object. |
| 101 | func open(opt Options) (*DB, error) { |
no test coverage detected