PgFlow.Slug (PgFlow v0.7.2)

Copy Markdown View Source

Upstream pgflow 0.17.2 slug rules (pgflow.is_valid_slug/1), mirrored for compile-time and pre-flight checks. The database remains authoritative.

Summary

Functions

Turns a validation reason into the message shown by the DSL and slug audit.

Finds the first group of slugs that share a lowercased name.

Maximum PGMQ queue name length. Flow slugs are lowercased into this budget.

Maximum flow or step slug length accepted by pgflow 0.17.2.

Returns the flow-mode queue name, which is the lowercased slug.

Returns true when slug satisfies every upstream slug rule.

Validates a flow or step slug and returns the first broken rule.

Rejects a queue name longer than the PGMQ limit.

Types

reason()

@type reason() ::
  :empty
  | :too_long
  | :bad_chars
  | :reserved
  | :bad_start
  | :bad_end
  | :double_underscore

Functions

describe(atom)

@spec describe(reason() | :queue_name_too_long) :: String.t()

Turns a validation reason into the message shown by the DSL and slug audit.

find_case_collision(slugs)

@spec find_case_collision([String.t() | atom()]) ::
  nil | {String.t(), [String.t() | atom()]}

Finds the first group of slugs that share a lowercased name.

Returns nil when every slug lowercases to a distinct name, or {lowercased, slugs} with the colliding slugs in input order.

max_queue_name_length()

@spec max_queue_name_length() :: pos_integer()

Maximum PGMQ queue name length. Flow slugs are lowercased into this budget.

max_slug_length()

@spec max_slug_length() :: pos_integer()

Maximum flow or step slug length accepted by pgflow 0.17.2.

queue_name(slug)

@spec queue_name(String.t() | atom()) :: String.t()

Returns the flow-mode queue name, which is the lowercased slug.

valid?(slug)

@spec valid?(String.t() | atom()) :: boolean()

Returns true when slug satisfies every upstream slug rule.

validate(slug)

@spec validate(String.t() | atom()) :: :ok | {:error, reason()}

Validates a flow or step slug and returns the first broken rule.

validate_queue_name(name)

@spec validate_queue_name(String.t()) :: :ok | {:error, :queue_name_too_long}

Rejects a queue name longer than the PGMQ limit.