Jidoka.Id (Jidoka v0.8.0-beta.1)

Copy Markdown View Source

Small boundary for generated Jidoka identifiers.

Core data constructors accept explicit IDs. When callers use convenience constructors without IDs, generation is routed through this module so entropy is isolated and tests can inject deterministic generators.

Summary

Functions

Generates an ID for a prefix using either the default generator or a caller-supplied generator.

Generates an ID or raises when the generator returns an invalid value.

Generates a random URL-safe identifier with the supplied prefix.

Types

generator()

@type generator() :: (prefix() -> String.t())

prefix()

@type prefix() :: String.t()

Functions

generate(prefix, generator \\ nil)

@spec generate(prefix(), generator() | nil) :: {:ok, String.t()} | {:error, term()}

Generates an ID for a prefix using either the default generator or a caller-supplied generator.

generate!(prefix, generator \\ nil)

@spec generate!(prefix(), generator() | nil) :: String.t()

Generates an ID or raises when the generator returns an invalid value.

random(prefix)

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

Generates a random URL-safe identifier with the supplied prefix.