snowflake
Version, currently 0.1.01 version
- 0.1.0latestFeb 25, 2024
github.com/mamantoha/snowflake
Snowflake ID generator implementation in Crystal programming language
0 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
snowflake:
github: mamantoha/snowflake
version: ~> 0.1.0Then run:
shards installshard.yml
- Crystal
>= 1.0.0- License
- MIT
- Author
- Anton Maminov
Dependencies
This version declares no dependencies.
README
Snowflake
Snowflake ID generator implementation in Crystal programming language, which is designed to generate unique, time-based identifiers using a 64-bit structure. These identifiers consist of a timestamp component, a machine or process ID, and a sequence number to ensure uniqueness within the same millisecond.
Installation
-
Add the dependency to your
shard.yml:dependencies: snowflake: github: mamantoha/snowflake -
Run
shards install
Usage
require "snowflake"
machine_id = 1_u64 # Assign a unique machine/process ID
generator = Snowflake.new(machine_id)
snowflake_id = generator.generate_id
puts snowflake_id
# To convert a Snowflake ID back to a UTC timestamp
utc_time = Snowflake.id_to_utc(snowflake_id)
puts utc_time
Contributing
- Fork it (https://github.com/mamantoha/snowflake/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Anton Maminov - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.0- Tagged
- Feb 25, 2024
- Commit
e0404a585918- Crystal
>= 1.0.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/mamantoha/snowflake
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 16, 2026
- Versions
- 1