Skip to content

SaurabhGoyal/snowflake-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snowflake

Snowflake is a crate that provides a simple implementation of unique-id generation based on Twitter's snowflake logic.

+--------------------------------------------------------------------------+
| 1 Bit Unused | 41 Bit Timestamp |  10 Bit NodeID  |   12 Bit Sequence ID |
+--------------------------------------------------------------------------+

Logic

  • There are two components - Generator and Config.
  • Config has a default implementation which provides 2 ^ 21 (2097152) unique ids per millisecond (1024 per node, across 2048 nodes) till year 2149 (~139 years from epoch). These values can be customised to support higher throughput or longer period of valid generation of unique IDs. Default config uses following details -
    • timestampBits - 42
    • nodeIdBits - 11

About

Implementation of snowflake uid generation in rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages