Documentation
¶
Overview ¶
Package snöflinga generates snowflake like 128-bit ids. The first 52 bits is a timestamp representing time since Unix epoch, in microseconds. The next 12 bits is a sequence number which is increased with each snowflake request, for collision avoidance. The start of the sequence is randomly selected. The final 64 bits is the id.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Flake ¶
type Flake [16]byte
Flake is the type for a 128 bit snowflake.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator creates snowflakes for a given id
func New ¶
New returns an initialized generator. If the passed byte slice's length is greater than 8 bytes, the first 8 bytes will be used for the generator's id. If the passed byte slice's is less than 8 bytes, the id will be left-padded with 0s, zeros. The generator's sequence is initialized with a random number.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package sne generates snowflake like 128 bit ids that uses milliseconds for the time element.
|
Package sne generates snowflake like 128 bit ids that uses milliseconds for the time element. |
|
Package snö generates snowflake like 128 bit ids that uses milliseconds for the time element, a 7 byte ID, and a 20 bit secondary id.
|
Package snö generates snowflake like 128 bit ids that uses milliseconds for the time element, a 7 byte ID, and a 20 bit secondary id. |
