rs-snowflake

Crates.iors-snowflake
lib.rsrs-snowflake
version0.6.0
sourcesrc
created_at2020-08-10 13:37:33.169696
updated_at2022-03-14 12:51:28.497567
descriptionRust version of the Twitter snowflake algorithm.
homepage
repositoryhttps://github.com/BinChengZhao/snowflake-rs.git
max_upload_size
id275043
size15,476
BinCheng (BinChengZhao)

documentation

https://docs.rs/rs-snowflake

README

snowflake-rs

Rust version of the Twitter snowflake algorithm .

A crate for quick generating distributed-ids.

API Docs: https://docs.rs/rs-snowflake

Usage

Add this to your Cargo.toml:

[dependencies]
rs-snowflake = "*"

Getting Started

use snowflake::SnowflakeIdGenerator;
fn main() {
   let mut id_generator_generator = SnowflakeIdGenerator::new(1, 1);
   let id = id_generator_generator.real_time_generate();
}
use snowflake::SnowflakeIdBucket;
fn main() {
   let mut id_generator_bucket = SnowflakeIdBucket::new(1, 1);
   let id = id_generator_bucket.get_id();
}
test bench_generate_get_id_by_bucket                      ... bench:           5 ns/iter (+/- 0)

test bench_generate_get_id_by_generator_general_version   ... bench:         232 ns/iter (+/- 32)

test bench_generate_get_id_by_generator_lazy_version      ... bench:           2 ns/iter (+/- 0)

test bench_generate_get_id_by_generator_real_time_version ... bench:         249 ns/iter (+/- 22)

test bench_generate_ids_by_bucket                         ... bench:      13,077 ns/iter (+/- 1,263)

License

Licensed under

Contribution

Thank you all very much for your contributions to the project, and if there is anything I can do to help, I would love to help!

Commit count: 20

cargo fmt