09 · Scheduling, calendars & triggers
Status: Implemented (T14) · Owner: Platform
Three things start runs besides a person pressing Run: schedules (time), trigger rules (events), and both can be shaped by global calendars. All three are versioned config items (design 10), so changes have history and can be rolled back. They always start the pipeline’s active version, through the same queue and limits as manual runs (design 03).
Calendars
Section titled “Calendars”Kind calendar, admin-only:
{"description": "Irish bank holidays", "dates": [{"date": "2026-08-03", "name": "August bank holiday"}], "ics_url": "https://calendars.example.com/ie-holidays.ics", "refresh": "0 3 * * *"}- Dates come from the list, an ICS feed, or both. All-day events become dates; multi-day events expand (DTEND is exclusive).
- Feeds are re-fetched on the
refreshcron (UTC; default daily at 03:00), and right away when a new calendar version is activated. Refreshed dates are data (calendar_dates), not a new config version. - A failed refresh keeps the last good dates and shows the error on the calendar.
- Feeds must be
https, at most 2 MB, and resolve to public addresses (they’re fetched from inside the cluster). Redirects aren’t followed.
Calendars are global: one “bank holidays” calendar serves every pipeline.
Schedules
Section titled “Schedules”Kind schedule (editor):
{"pipeline": "monthly-revenue", "enabled": true, "timezone": "Europe/Dublin", "when": {"kind": "business_day", "nth": 1, "time": "06:00"}, "skip_calendars": ["ie-bank-holidays"], "only_calendars": [], "catch_up": "once"}when.kind |
Fields | Fires |
|---|---|---|
cron |
cron |
Standard 5-field cron, in timezone |
interval |
every_s (≥ 60) |
Every N seconds after the previous fire |
once |
at (local ISO time) |
Once |
business_day |
nth (1–23, or -1 = last), time |
The nth Monday–Friday of each month that isn’t in skip_calendars |
- Cron is evaluated in local wall-clock time, so
0 6 * * *inEurope/Dublinruns at 06:00 local on both sides of a daylight-saving change. skip_calendars: never on those dates (and they aren’t business days).only_calendars: only on those dates (e.g. a month-end calendar).- Activation checks that the pipeline and calendars exist.
The scheduler runs in the API. Every tick (FLUX_SCHEDULER_TICK_S, 10 s) it
refreshes due calendars, then for each active, enabled schedule:
- A new or changed active version computes its next time from now.
- When the next time has passed, it fires: a
firingsrow keyed byschedule + scheduled time(so a time fires once, even if a tick is retried) and a queued run withtrigger: "schedule"and the scheduled time. - The next time is computed from now.
Downtime. A time missed by more than 5 minutes follows catch_up: once runs one
catch-up run (not one per missed time), skip runs nothing. Either way the schedule
continues from the next future time.
One scheduler. Each API process tries to take a Postgres advisory lock on a dedicated connection; only the holder schedules. If it dies, the lock is released and another process takes over on its next tick.
Trigger rules
Section titled “Trigger rules”Kind trigger (editor):
{"pipeline": "refresh-dashboards", "enabled": true, "on": "flux.run.status", "match": {"status": "succeeded", "pipeline": ["load-orders", "load-customers"]}, "cooldown_s": 300, "skip_calendars": [], "timezone": "UTC"}onis an event type (design 08):flux.run.status,flux.run.node,flux.dataset.committed,flux.forge.published/revoked,flux.trigger.fired, orflux.external.<name>.matchcompares event data fields (dotted paths) for equality; a list means any of. The orchestrator’s run status events carrypipeline,versionandtrigger.cooldown_s: after a trigger starts a run, further matches within the cooldown are ignored.- A
flux.run.statusrule must match another pipeline’s runs (match.pipeline), so a pipeline can’t re-trigger itself forever. Chains across pipelines are allowed.
Evaluation. The event indexer evaluates active rules for every indexed event, in the same database transaction that stores the event. The firing is keyed by rule + event id, so a redelivered event never starts a second run. Rules are cached for 3 seconds, so a new rule applies within seconds.
External events. POST /api/events/external/{name} (editor) publishes
flux.external.<name> with the JSON body as data (at most 16 KB), for other systems to
start pipelines, for example from a webhook. They’re kept 30 days in the FLUX_EXTERNAL
stream.
Firings and events
Section titled “Firings and events”Every firing is recorded (GET /api/firings?kind=&key=) with the run it started, or why
it didn’t (for example: the pipeline has no active version). The firings table doubles as
an outbox: the scheduler publishes flux.trigger.<key>.fired for each firing and marks it
published, so the event is never lost if NATS is briefly unavailable.
| Endpoint | |
|---|---|
/api/config/{schedule,trigger,calendar}/… |
Definitions, versions, activation, rollback |
POST /api/schedules/preview |
Next fire times of a draft schedule, calendars applied |
GET /api/schedules/state |
Next and last fire per schedule |
GET /api/calendars/{key}/dates, POST …/refresh (admin) |
Dates, refresh status |
GET /api/firings |
Recent firings |
POST /api/events/external/{name} |
External event |
The app’s Automation page manages all three, with a live preview of the next runs.
Tested
Section titled “Tested”Fire times (cron across DST, calendars, business days, intervals, once), ICS parsing and refresh with failure handling, admin-only calendars, the scheduler firing once per time and handling downtime, schedule activation checks, trigger matching with lists, redelivery, cooldown and loop protection, and, against live NATS, an external event firing a rule and the firing event arriving through the outbox.
Open questions
Section titled “Open questions”- File-arrival triggers for drop folders (a polling sensor that emits an event).
- Per-schedule run parameters once pipelines take parameters.
See the architecture overview.