Skip to content

mikan-laboratory/snowglake

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snowglake ❄️

Package Version Hex Docs

Gleam version of the Twitter's snowflake format for unique IDs. Although it is more inspired by the Discord implementation of the snowflake format.

They are great for generating unique IDs in a distributed system.

This package is based on the snowgleam library, updated to work with the latest Gleam releases.

gleam add snowglake

And then use it in your project like this:

import gleam/io
import gleam/int
import snowglake

pub fn main() {
  let assert Ok(generator) = snowglake.new_generator() |> snowglake.start()
  let id = generator |> snowglake.generate()
  io.println("Generated ID: " <> id |> int.to_string())

  generator |> snowglake.stop()
}

Features

  • Setup with a custom epoch
  • Simple ID generation
  • Lazy ID generation
  • Lazy ID generation with custom timestamp (useful for backfilling)
  • Batch ID generation
  • Batch Lazy ID generation

Further documentation can be found at https://hexdocs.pm/snowglake.

About

❄️ Gleam version of the Twitter's snowflake format for unique IDs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Gleam 100.0%