Available on crate features
serve and triggers only.Expand description
Event-driven pipeline triggers for faucet serve (#196).
A static --triggers <file> defines watchers (object-arrival / webhook /
queue-depth) that, on fire, enqueue a run via crate::serve::runner::submit
— reusing the whole queue/executor/idempotency pipeline. Pure decision logic
(spec validation, ${trigger.*} substitution, cursors, edge detection) is
separated from the IO shell (watchers, fire path, webhook route).
Re-exports§
pub use compiled::CompiledTriggers as Compiled;
Modules§
- compiled
- Validated form of a
TriggersFile.compilesurfaces every problem at startup (unique names, webhook-path collisions, resolvable pipeline ref, interval/threshold bounds, missing backend feature) so a watcher never fails mid-run from a config mistake. Pure (no IO except reading a path’s existence, which is done by the caller; here we only validate shapes). - context
- The fired event (
TriggerEvent) and pure derivations from it:${trigger.*}text substitution, the deterministic idempotency key, and the auto run-labels. No IO. - enqueue
- The single choke point all trigger fires funnel through.
build_submit_requestis pure (text + event → SubmitRequest);fireresolves the pipeline ref, substitutes, submits via the existing runner, and maps the outcome. - health
- Per-watcher health, shared with
/readyz. ATriggersHandleis an Arc-backed, cheaply-cloneable handle stored inServerState(mirrorsClusterHandle). - metrics
faucet_serve_trigger_*metrics. Low-cardinality labels only (triggername,type). Mirrorscrate::schedule::metrics.- object_
arrival triggers-object-store object_arrivaltrigger: incremental S3/GCS prefix listing. The pureCursordecides which listed objects are new; the watcher (Task 13) does IO.- queue_
depth triggers-kafkaortriggers-redis queue_depthtrigger: poll a queue’s depth and fire edge-triggered (once per rising crossing ofthreshold, suppressed until it drains). TheEdgeis pure;DepthProbeis the IO seam (Redis/Kafka impls + a fake in tests).- spec
- Serde config types for the
--triggersfile. Pure data +JsonSchema; no IO. Validation lives incompiled.rs. - watcher
- The
Watchertrait + the supervised polling loop. A watcher never dies on a transient error: it records health, backs off, and retries until shutdown. - webhook
POST/PUT /v1/triggers/{name}— the webhook trigger endpoint. Looks the name up in theTriggersHandlewebhook table, checks the method allowlist, applies a leading-edge debounce (coalesce fires that arrive withindebounce_secsof the last accepted fire), builds aTriggerEvent::Webhook, and fires. Bearer auth is inherited from the/v1route_layer.
Functions§
- load_
triggers - Load + validate a triggers file. Surfaces a clear
CliError::Serveon any parse/validation failure (fail-fast at startup). - spawn_
watchers - Spawn supervised watcher tasks for every enabled polling trigger. Webhook triggers need no task (they are served by the route). Returns the join handles (the caller aborts them on shutdown, like the maintenance/lease loops).