Skip to main content

schema_config_toml/
lib.rs

1//! Parse `flusso.toml` into neutral [`ConfigToml`] entities.
2//!
3//! A config file declares the Postgres source, the sinks documents are written
4//! to, and the indexes to build. This crate handles only the **parse** stage:
5//! [`ConfigToml`] deserializes the file verbatim, rejecting unknown fields, into
6//! entity types that mirror the file 1:1 and reference only the `schema-core`
7//! vocabulary. Lifting these entities into the assembled `Config` is a
8//! composition step that lives in the `schema` crate (`From<ConfigToml>`), so
9//! this parser sits at the bottom layer and never depends on `Config`.
10//!
11//! Secrets are **not** resolved here. Any string value may be given literally or
12//! as `{ env = "VAR" }`; the entities carry that choice through unchanged so the
13//! value can be read in the environment that runs the pipeline.
14
15pub mod entities;
16mod env_value;
17mod parser;
18
19pub use env_value::EnvOrValue;
20pub use parser::ParseError;
21
22/// The JSON Schema describing a `flusso.toml` config file, embedded from this
23/// crate's `schemas/` directory for editor assist and programmatic access (both
24/// re-exported from `schema` and emitted by `flusso schema config`). Kept in
25/// lockstep with this parser by `schema`'s `schema_drift` test.
26pub const CONFIG_SCHEMA: &str = include_str!("../config.schema.json");
27
28use serde::{Deserialize, Serialize};
29use std::collections::BTreeMap;
30
31use entities::IndexEntry;
32use entities::Server;
33use entities::Sink;
34use entities::Source;
35use schema_core::common;
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(deny_unknown_fields)]
39pub struct ConfigToml {
40    pub source: Source,
41    #[serde(default)]
42    pub sinks: BTreeMap<common::SinkName, Sink>,
43    #[serde(default)]
44    pub index: Vec<IndexEntry>,
45    /// Global item-level rejection policy; per-index overrides live on each
46    /// [`IndexEntry`]. Defaults to [`FailurePolicy::Stop`](schema_core::FailurePolicy::Stop).
47    #[serde(default)]
48    pub on_error: schema_core::FailurePolicy,
49    /// Bind addresses for the operational HTTP surfaces. The binary layers
50    /// `FLUSSO_*` env vars and CLI flags on top (which win); see `CONFIG.md`.
51    #[serde(default)]
52    pub server: Server,
53}