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

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

Search Document