Documentation ¶
Overview ¶
Package flother is an implementation of Twitter's Snowflake 64-bit ID generation.
See: https://blog.twitter.com/2010/announcing-snowflake or: http://instagram-engineering.tumblr.com/post/10853187575/sharding-ids-at-instagram
Index ¶
Constants ¶
const DEFAULT_NODE_BITS = 13
DEFAULT_NODE_BITS is set to 13 bits to allow for 8192 nodes.
const DEFAULT_TIME_BITS = 41
DEFAULT_TIME_BITS is set to 41 bits to allow for almost 70 years of ids with an epoch.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Flother ¶
type Flother struct {
// contains filtered or unexported fields
}
func NewFlother ¶
NewFlother returns a *Flother can be used to generate unique ids.
epoch is the offset to use for the id generation.
node is the unique node id for this server / application.
timeBits are the number of bits to use to represent the time; recommended DEFAULT_TIME_BITS.
nodeBits are the number of bits to use to represent the unique node; recommended DEFAULT_NODE_BITS.