LemonCore.Id (lemon_core v0.1.0)

View Source

ID generation utilities for Lemon.

Provides consistent ID generation for runs, sessions, and other entities.

Summary

Functions

Generate an approval ID.

Generate a cron job ID.

Generate an idempotency key for a scope and operation.

Generate a run ID.

Generate a session ID.

Generate a skill ID.

Generate a time-ordered UUID v7.

Generate a random UUID v4.

Functions

approval_id()

@spec approval_id() :: binary()

Generate an approval ID.

cron_id()

@spec cron_id() :: binary()

Generate a cron job ID.

idempotency_key(scope, operation)

@spec idempotency_key(scope :: binary(), operation :: binary()) :: binary()

Generate an idempotency key for a scope and operation.

Examples

iex> key = LemonCore.Id.idempotency_key("messages", "send")
iex> String.starts_with?(key, "messages:send:")
true

run_id()

@spec run_id() :: binary()

Generate a run ID.

Run IDs are UUID v4 with a "run_" prefix for easy identification.

Examples

iex> id = LemonCore.Id.run_id()
iex> String.starts_with?(id, "run_")
true

session_id()

@spec session_id() :: binary()

Generate a session ID.

Session IDs are UUID v4 with a "sess_" prefix for easy identification.

Examples

iex> id = LemonCore.Id.session_id()
iex> String.starts_with?(id, "sess_")
true

skill_id()

@spec skill_id() :: binary()

Generate a skill ID.

uuid7()

@spec uuid7() :: binary()

Generate a time-ordered UUID v7.

Sorts lexicographically by creation time, unlike uuid/0.

uuid()

@spec uuid() :: binary()

Generate a random UUID v4.