snowflake_uid

Crates.iosnowflake_uid
lib.rssnowflake_uid
version0.1.1
sourcesrc
created_at2024-05-05 10:44:18.429359
updated_at2024-05-06 04:54:44.532228
descriptionA module for generating guaranteed unique IDs among a cluster of nodes using Snowflake logic.
homepagehttps://github.com/SaurabhGoyal/snowflake-rs
repositoryhttps://github.com/SaurabhGoyal/snowflake-rs
max_upload_size
id1230155
size10,167
Saurabh Goyal (SaurabhGoyal)

documentation

https://docs.rs/snowflake_uid

README

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
Commit count: 9

cargo fmt