Documentation
¶
Overview ¶
Package snowflake provides a very simple Twitter snowflake generator.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultEpoch is the default snowflake start timestamp epoch of 2020-01-01 00:00:00 UTC in milliseconds. DefaultEpoch int64 = 1577836800000 )
Functions ¶
This section is empty.
Types ¶
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
An ID is a custom type used for a snowflake ID. This is used so we can attach methods onto the ID.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is a struct holds the basic information needed for a snowflake generator
func CustomNode ¶
CustomNode create a custom snowflake node.
func NewNode ¶
NewNode returns a new snowflake node that can be used to generate snowflake ID. The default epoch: 2000-01-01 00:00:00 UTC The default ID format: +----------------------------------------------------------------------+ | 1 Bit Unused | 41 Bit Timestamp | 10 Bit NodeID | 12 Bit Sequence ID | +----------------------------------------------------------------------+ @see https://en.wikipedia.org/wiki/Snowflake_ID