Bedrock.Internal.Id (bedrock v0.5.3)

View Source

Centralized ID generation utilities.

Generates cryptographically random IDs encoded as base32 lowercase strings. Used for worker IDs, cluster IDs, and other unique identifiers.

Examples

iex> id = Bedrock.Internal.Id.random()
iex> String.length(id)
8

iex> id = Bedrock.Internal.Id.random(4)
iex> String.length(id)
7

Summary

Functions

Generates a random ID with default entropy (5 bytes = 8 characters).

Generates a random ID with the specified number of entropy bytes.

Functions

random()

@spec random() :: String.t()

Generates a random ID with default entropy (5 bytes = 8 characters).

random(bytes)

@spec random(bytes :: pos_integer()) :: String.t()

Generates a random ID with the specified number of entropy bytes.

The resulting string length is ceil(bytes * 8 / 5) characters.