Synaptic.Workflow (synaptic v0.1.5)

View Source

DSL entry point for defining Synaptic workflows.

Summary

Functions

Declares an asynchronous fire-and-forget workflow step. The block receives the accumulated context and executes like a normal step, but the workflow immediately continues to the next step instead of waiting for this one to finish. Results are merged back into the context once the step completes.

Marks that the workflow definition has declared its terminal point. In the MVP the macro only exists to nudge authors so that tests reflect the full lifecycle.

Produces the compiled workflow definition for the provided module.

Declares a parallel workflow step. The block must return a list of anonymous functions that receive the workflow context (map). Each function runs concurrently and must return {:ok, map} or {:error, term}. The step succeeds only when all parallel tasks succeed, and their maps are merged into the accumulated context.

Declares a ordered workflow step. The block receives context (map) accumulated from every previous step and must return {:ok, map}, {:error, term}, or suspend_for_human/2.

Convenience helper returned from steps to pause execution and wait for a human payload to resume the workflow.

Functions

async_step(name, opts \\ [], list)

(macro)

Declares an asynchronous fire-and-forget workflow step. The block receives the accumulated context and executes like a normal step, but the workflow immediately continues to the next step instead of waiting for this one to finish. Results are merged back into the context once the step completes.

commit()

(macro)

Marks that the workflow definition has declared its terminal point. In the MVP the macro only exists to nudge authors so that tests reflect the full lifecycle.

definition(module)

@spec definition(
  atom()
  | %{:__synaptic_definition__ => any(), optional(any()) => any()}
) :: any()

Produces the compiled workflow definition for the provided module.

parallel_step(name, opts \\ [], list)

(macro)

Declares a parallel workflow step. The block must return a list of anonymous functions that receive the workflow context (map). Each function runs concurrently and must return {:ok, map} or {:error, term}. The step succeeds only when all parallel tasks succeed, and their maps are merged into the accumulated context.

step(name, opts \\ [], list)

(macro)

Declares a ordered workflow step. The block receives context (map) accumulated from every previous step and must return {:ok, map}, {:error, term}, or suspend_for_human/2.

suspend_for_human(message, metadata \\ %{}, context_updates \\ %{})

Convenience helper returned from steps to pause execution and wait for a human payload to resume the workflow.