Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Snowflake ¶
Snowflake 24小时内不会重复的雪花序号生成器 构成为: 0 | seconds 17 bit | datacenter 2 bit | worker 3 bit| sequence 9 bit 最大支持32个节点,单节点TPS不超过512,超过则会阻塞程序到下一秒再返回序号,仅能用于特殊场景 seconds占用17bits是因为一天86400秒占用17bits
func NewSnowflake ¶
NewSnowflake d for datacenter-id, w for worker-id
Click to show internal directories.
Click to hide internal directories.