snowflake-srv

command module
v0.0.0-...-74704ee Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

README

Snowflake

Build Status

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

  1. 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

  2. Run Consul

    $ consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul
    
  3. Download and start the service

    go get github.com/unicok/snowflake-srv
    ./snowflake-srv
    

The API

  • GetUUID
  • Next
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) --|

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
proto
snowflake
Package snowflake is a generated protocol buffer package.
Package snowflake is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL