WorkflowStem.Pipeline.Builder (workflow_stem v0.2.0)

Copy Markdown View Source

Emits a runtime-compiled ALF pipeline module from a spec's compiled descriptors.

Takes descriptors produced by WorkflowStem.Compiler.components_for/1 plus the spec's :routing table, and generates an Elixir module that:

  • does use ALF.DSL
  • exposes @components [...] matching the descriptor list
  • carries defdelegate entries for every routing name, so ALF's switch/goto components resolve via apply(pipeline_mod, name, args)

The generated module is compiled into the current BEAM via Code.compile_quoted/1. Callers get back {:ok, module_name}; the module is callable immediately.

Typical usage:

{:ok, mod} =
  WorkflowStem.Pipeline.Builder.build(
    MyAgent.Pipeline.SomeWorkflow,
    Compiler.components_for(spec),
    Map.get(spec, :routing, %{})
  )

:ok = mod.start()
result = mod.call(event)

Scope in this iteration

AST emission is implemented for: stage, switch, composer, goto, goto_point, done, dead_end, from, tbd. Support for plug_with follows the same pattern but is not yet emitted — a descriptor of {:plug_with, ...} will raise here. (The Compiler accepts and validates it; Builder just hasn't rendered the AST yet.)

Summary

Functions

Build and compile a pipeline module. Returns {:ok, module} on success.

Functions

build(module_name, descriptors, routing)

@spec build(module(), [tuple()], map()) :: {:ok, module()}

Build and compile a pipeline module. Returns {:ok, module} on success.

Raises ArgumentError if a descriptor has no AST emitter yet (currently :plug_with).