Synaptic.Workflow (synaptic v0.2.6)
View SourceDSL 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.
Marks a code block as a side effect (e.g., database mutations, external API calls).
When skip_side_effects: true is set in test configuration, the side effect
is skipped and returns a default value instead.
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
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.
@spec definition( atom() | %{:__synaptic_definition__ => any(), optional(any()) => any()} ) :: any()
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.
Marks a code block as a side effect (e.g., database mutations, external API calls).
When skip_side_effects: true is set in test configuration, the side effect
is skipped and returns a default value instead.
Options
:default- Value to return when side effect is skipped (default::ok):name- Optional identifier for the side effect, used in Telemetry metadata
Examples
step :save_user do
side_effect do
Database.insert(context.user)
end
{:ok, %{user_saved: true}}
end
step :send_email do
side_effect default: {:ok, :sent}, name: :welcome_email do
EmailService.send(context.user.email, "Welcome!")
end
{:ok, %{email_sent: true}}
end
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.