Reference

Functions

Breyta functions reference for reusable Clojure transforms in :function steps.

Quick Answer

Define transform logic once in :functions and call by stable :ref from flow/step :function to keep orchestration small and deterministic.

What Functions Are

functions define reusable Clojure transforms referenced by :function steps.

  • isolate shaping and normalization logic
  • keep orchestration readable
  • avoid duplicating transform code across steps

Definition Shape

Declare functions at top level:

{:functions [{:id :summarize
              :language :clojure
              :code "(fn [input] {:count (count (:rows input))})"}]}

Call from flow:

(flow/step :function :summarize-rows
  {:ref :summarize
   :input {:rows rows}})

Authoring Guidelines

  • keep function logic pure and deterministic
  • use functions for data transformation, not external side effects
  • use :function steps for non-trivial shaping/normalization, even if used once
  • keep inline :flow code focused on orchestration (ordering, branching, retries, waits)
  • keep ids stable; avoid renaming unless intentional
  • prefer multiline flow files over long one-line string literals

Runtime Notes

  • function code is resolved by :ref from the flow definition
  • when running a function step in isolation via CLI, include --flow <slug> so refs resolve
  • only allowlisted Java interop is available in the function runtime

Troubleshooting

  • unresolved :ref: confirm function id exists and matches exactly
  • parse/EDN failures: validate file structure and avoid accidental escaped newlines outside strings
  • runtime errors: run step in isolation first, then run full flow after fix

Related

As of Feb 13, 2026