Crucible.Registry (CrucibleFramework v0.5.2)

View Source

Resolves stage modules from application configuration.

Stages can be resolved either by:

  1. Explicit module specification in the StageDef struct
  2. Name-based lookup from the configured stage registry

Configuration

Configure the stage registry in your application config:

config :crucible_framework,
  stage_registry: %{
    validate: Crucible.Stage.Validate,
    bench: Crucible.Stage.Bench,
    report: Crucible.Stage.Report,
    # Add custom stages here
    my_stage: MyApp.Stage.Custom
  }

Schema Access

The registry provides functions to access stage schemas:

Crucible.Registry.list_stages_with_schemas()
# => [{:bench, Crucible.Stage.Bench, %{name: :bench, ...}}, ...]

Crucible.Registry.stage_schema(:bench)
# => {:ok, %{name: :bench, description: "...", ...}}

Summary

Functions

Lists all registered stage names.

Lists all registered stages with their modules and schemas.

Resolves a stage module by name from the configured registry.

Gets the schema for a specific registered stage by name.

Functions

list_stages()

@spec list_stages() :: [atom()]

Lists all registered stage names.

Examples

Crucible.Registry.list_stages()
# => [:bench, :data_checks, :guardrails, :report, :validate]

list_stages_with_schemas()

@spec list_stages_with_schemas() :: [{atom(), module(), map()}]

Lists all registered stages with their modules and schemas.

Returns a list of tuples {name, module, schema} for each registered stage. Schemas are normalized to canonical format.

Examples

Crucible.Registry.list_stages_with_schemas()
# => [
#      {:bench, Crucible.Stage.Bench, %{name: :bench, ...}},
#      {:validate, Crucible.Stage.Validate, %{name: :validate, ...}}
#    ]

stage_module(name)

@spec stage_module(atom()) :: {:ok, module()} | {:error, term()}

Resolves a stage module by name from the configured registry.

Examples

{:ok, Crucible.Stage.Bench} = Crucible.Registry.stage_module(:bench)
{:error, {:unknown_stage, :missing}} = Crucible.Registry.stage_module(:missing)

stage_schema(name)

@spec stage_schema(atom()) ::
  {:ok, Crucible.Stage.Schema.t()}
  | {:error,
     :no_stage_registry
     | {:no_describe_callback, atom()}
     | {:unknown_stage, atom()}}

Gets the schema for a specific registered stage by name.

Returns {:ok, schema} with the normalized schema, or {:error, reason} if the stage is not found or has no schema.

Examples

{:ok, schema} = Crucible.Registry.stage_schema(:bench)
schema.name
# => :bench

{:error, {:unknown_stage, :missing}} = Crucible.Registry.stage_schema(:missing)