leaves 0.4.0-beta.1

Distributed ID Allocator
Documentation

Leaves: Distributed ID Generation Service

This is a unofficial port of Leaf.

🏠 Homepage

Latest version

Features

  • generate id in segment mode
  • generate id in snowflake mode
  • mysql
  • redis
  • postgresql
  • sqlite
  • mongodb
  • runtime-agnostic(tokio or async-std) when using mysql or postgres
  • http server or rpc service(actually just implement it by yourself 😂)

TODO

  • more configurable
  • performance
  • lazy fetch

Example

Enabling the mysql and runtime-tokio feature:

use leaves::dao::mysql::MySqlLeafDao;
use leaves::LeafSegment;
use leaves::Result;

#[tokio::main]
async main() -> Result<()> {
    let dao = Arc::new(MySqlLeafDao::new("mysql://...").await?);
    let mut service = LeafSegment::new(dao);
    service.init().await?;
    let tag = 1;
    for _ in 0..1000 {
        println!("{}", service.get(tag).await?);
    }
}

Benchmark

200,000qps using a in-memory mock db (not strict benchmark)