/fireflake

🔥Fireflake - implementation of Snowflake ID in Mojo.

Primary LanguageMojoApache License 2.0Apache-2.0

🔥 Fireflake

Implementation of Snowflake ID for Mojo 🔥.


Logo

🔥 Fireflake

Written in Mojo Apache-2.0 license Build status
Contributors Welcome

Requirements

  • Mojo: mojo 24.5.0 (e8aacb95). Should work in future versions.
  • Python: 3.7+

Getting started

  1. 🌩️ Download fireflake.mojopkg from releases.
  2. 🗄️ Place it in your project working directory.
  3. 📝 Follow the usage guideline below.

Usage

from fireflake import Fireflake

fn main() raises:
    # Generate new id with default config - Twitter/X style Snowflake ID.
    fireflake = Fireflake()
    new_id = fireflake.generate()
    print(new_id)

    # Generate new id with custom config for nodes/sequence bit count.
    fireflake2 = Fireflake[node_bits_count=7, sequence_bits_count=15]()
    new_id = fireflake2.generate()
    print(new_id)

    # Generate new id with default config but provide a custom number - which
    # could be hash of your data or any other meaningful number you select.
    fireflake3 = Fireflake()
    new_id = fireflake3.generate(1234)
    print(new_id)

Check out other Mojo libraries: