Twitter's Snowflake UUID generator in Erlang.
Go to file
2012-07-25 18:28:48 -04:00
src Made versioning follow git tags 2012-07-05 21:39:41 -04:00
test Major changes to the package and design! 2012-06-13 01:43:18 -04:00
.gitignore Initial commit. 2012-06-08 10:00:39 -04:00
Makefile Major changes to the package and design! 2012-06-13 01:43:18 -04:00
README.md * README.md: Todos added 2012-06-28 13:38:45 -04:00
rebar Initial commit. 2012-06-08 10:00:39 -04:00
rebar.config Returning to the original rebar dep methods. 2012-07-25 18:28:48 -04:00

Snowflake: a 64-bit UUID generator

Original design by Twitter.

1> application:start(snowflake).
2> snowflake:new().
<<0,231,97,68,12,192,0,0>>
3> snowflake:serialize(snowflake:new()).
<<"AOdiTg5AAAA=">>
4> sets:size(sets:from_list([snowflake:new() || _I <- lists:seq(1,100000)])).
100000
5> lists:map(fun ({T, _}) -> T end,[timer:tc(snowflake, new, []) || _I <- lists:seq(1,100)]).
[93,46,42,42,42,53,55,43,42,43,73,36,34,33,39,52,48,39,35,
 54,36,34,33,34,40,35,33,33,34|...]

To do

  • Fix for NTP adjustments

    Sometimes NTP will repeat milliseconds, but this violates the strict ordering of snowflake. Snowflake should keep track of the last seen time and wait until NTP catches back up so as to ensure monotonicity.