Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator struct { StartTime int64 // contains filtered or unexported fields }
Generator is a fountain for new snowflakes. StartTime must be initialized to a past point in time and Instance ID can be any positive value or 0.
If any value is not correctly set, new IDs cannot be produced.
func (*Generator) NewID ¶
NewID generates a new, unique snowflake value
Up to 8192 snowflakes per second can be requested If exhausted, it blocks and sleeps until a new second of unix time starts.
The return value is signed but always positive.
Additionally, the return value is monotonic for a single instance and weakly monotonic for many instances.
Click to show internal directories.
Click to hide internal directories.