Skip to content

huangjj27/snowflake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SnowFlake

The snowflake crate(not available on cargo currently) is an implement of twitter's snowflake algorithm written in rust. Currently it generate uuid as follows:

  • 1 bit for unused sign bit
  • 41 bits for milliseconds timestamp since std::time::UNIX_EPOCH
  • 10 bits for generator id:
    • 5 bits for datacenter id
    • 5 bits for worker id in specific datacenter
  • rest 12 bits for sequence id generated in the same timestamp at the generator

In fact, the bits of the each three information can be flow, as long as they can form a 64 bit that can be store in an i64

TODO:

  • make the bits of information configurable
  • make the codes more neat
  • make the EPOCH time configurable
  • optimize the block time counting

author by h_ang!(J27);

About

a rust implement of twitter snowflake

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages