Git Product home page Git Product logo

snowflake's Introduction

SNOWFLAKE

Build Status

设计理念

  1. 分布式uuid发生器,twitter snowflake的go语言版本
  2. 序列发生器

uuid格式为:

+-------------------------------------------------------------------------------------------------+
| UNUSED(1BIT) |         TIMESTAMP(41BIT)           |  MACHINE-ID(10BIT)  |   SERIAL-NO(12BIT)    |
+-------------------------------------------------------------------------------------------------+

安装

默认情况下uuid发生器依赖的snowflake-uuid键值对必须预先在etcd中创建,snowflake启动的时候会读取,例如:

   curl http://172.17.42.1:2379/v2/keys/seqs/snowflake-uuid -XPUT -d value="0"          

这个snowflake-uuid会用于MACHINE-ID的自动生成,如果完全由用户自定义machine_id,可以通过环境变量指定,如:

   export MACHINE_ID=123

如果要使用序列发生器Next(),必须预先创建一个key,例如:

   curl http://172.17.42.1:2379/v2/keys/seqs/userid -XPUT -d value="0"          

其他部分参考Dockerfile

使用

snowflake 参考测试用例和snowflake.proto

环境变量

ETCD_HOST: eg: http://172.17.42.1:2379
MACHINE_ID: eg: 123

snowflake's People

Contributors

en avatar johnnyluo586 avatar tenywen avatar xtaci avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.