BeamConsole.EntityId (beam_console v0.5.3)

Copy Markdown View Source

Builds stable, opaque identifiers and bounded labels for runtime entities.

IDs are safe to place in URLs and browser DOM attributes. They deliberately avoid accepting encoded Erlang terms back from clients.

Summary

Functions

Builds a deterministic, kind-prefixed identifier from an Erlang term.

Converts a safe runtime value into a bounded display label.

Functions

build(kind, identity)

@spec build(atom(), term()) :: String.t()

Builds a deterministic, kind-prefixed identifier from an Erlang term.

Examples

iex> id = BeamConsole.EntityId.build(:application, :logger)
iex> String.starts_with?(id, "app_")
true
iex> id == BeamConsole.EntityId.build(:application, :logger)
true

label(value, limit \\ 96)

@spec label(term(), non_neg_integer()) :: String.t()

Converts a safe runtime value into a bounded display label.

Values outside the allowlisted scalar types are rendered as opaque children.

Examples

iex> BeamConsole.EntityId.label(:worker)
"worker"
iex> BeamConsole.EntityId.label("abcdefgh", 4)
"abcd…"
iex> BeamConsole.EntityId.label({:private, :term})
"opaque child"