Discover Packages
github.com/unicok/snowflake-srv
command
module
Version:
v0.0.0-...-74704ee
Opens a new window with list of versions in this module.
Published: Nov 11, 2016
License: Apache-2.0
Opens a new window with license information.
Imports: 6
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
README
¶
Snowflake
Snowflake is a network service for generating unique ID numbers at high scale with some simple guarantees. http://twitter.com/
This is a go language version based on Consul KV
Getting started
Install Consul
Consul is the default registry/discovery for go-micro apps. It's however pluggable.
https://www.consul.io/intro/getting-started/install.html
Run Consul
$ consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul
Download and start the service
go get github.com/unicok/snowflake-srv
./snowflake-srv
The API
UUID:
unused - 1 bit
time - 41 bits (millisecond precision w/ a custom epoch gives us 69 years)
configured machine id - 10 bits - gives us up to 1024 machines
sequence number - 12 bits - rolls over every 4096 per machine (with protection to avoid rollover in the same ms)
|-- UNUSED(1BIT) --|-- TIMESTAMP(41BIT) --|-- MACHINE-ID(10BIT) --|-- SERIAL-NO(12BIT) --|
Expand ▾
Collapse ▴
Documentation
¶
There is no documentation for this package.
Source Files
¶
Directories
¶
proto
snowflake
Package snowflake is a generated protocol buffer package.
Package snowflake is a generated protocol buffer package.
Click to show internal directories.
Click to hide internal directories.