Snowgleam ❄️

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.

gleam add snowgleam

And then use it in your project like this:

import gleam/io
import gleam/int
import snowgleam

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

  generator |> snowgleam.stop()
}

Features

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

Search Document