Scheduled Rollup
Breyta scheduled workflow example for cron-triggered rollup jobs.
Quick Answer
Use a :schedule trigger with cron config and :concurrency :drain for predictable handover between flow versions.
Use a top-level function for output shaping, keeping the :flow body orchestration-only and labeling orchestration branches.
Use Case
Run periodic aggregation on a schedule.
Full Definition
{:slug :scheduled-rollup
:name "Scheduled Rollup"
:concurrency {:type :singleton :on-new-version :drain}
:functions [{:id :build-rollup-output
:language :clojure
:code "(fn [input] {:type :rollup :run-at (:run-at input) :input (:input input)})"}]
:triggers [{:type :schedule
:label "Every 15m"
:enabled true
:config {:cron "*/15 * * * *"}}]
:flow
'(let [run-at (flow/step :time :now {})
input (flow/input)
rollup-input ^{:label "Rollup input source"
:yes "Use override payload"
:no "Use schedule/manual input"}
(if (:override input)
(:override input)
input)
output (flow/step :function :build-output
{:ref :build-rollup-output
:input {:run-at run-at
:input rollup-input}})]
output)}
Expected Behavior
A new run executes on schedule and produces rollup payload metadata.
Notes
Use :drain when overlapping versions should finish before switching.
Operational guidance:
- schedule trigger means runs are time-based, not manually started by default
- choose a short cron interval in non-prod during validation
- keep output lightweight for periodic workloads
:drainlets in-flight runs finish before a new released version takes over
Validation tip:
- release flow
- wait one or two schedule intervals
- inspect latest runs and confirm
:run-atchanges per run