Skip to content

šŸ”„Fireflake - implementation of Snowflake ID in Mojo.

License

Notifications You must be signed in to change notification settings

sazid/fireflake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Ā 

History

6 Commits
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 

Repository files navigation

šŸ”„ 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: