Skip to main content

sources_core/
lib.rs

1//! The source abstractions for `flusso`.
2//!
3//! A source has two **independent** responsibilities, each its own module.
4//! Neither module references the other; the engine is the only thing that
5//! bridges them.
6//!
7//! - [`cdc`] — *what changed?* A pluggable change-capture mechanism that yields
8//!   a stream of thin [`Change`](cdc::Change)s and confirms progress via an
9//!   [`Ack`](cdc::Ack). Logical replication (WAL) is the first mechanism;
10//!   polling or triggers can follow.
11//! - [`document`] — *what to build?* Turns a changed row (named by table and
12//!   key) into the target documents it affects, and assembles each one.
13//!
14//! Alongside them, [`validate_indexes`] is the source-independent
15//! half of a check every source can offer: a self-describing schema states its
16//! own types, so the mapping is derived without a database, and a reachable
17//! database is used only to confirm the declared types and nullability match
18//! the real columns. A source supplies only the one store-specific piece — a
19//! [`Catalog`] over its column types.
20//!
21//! [`CaptureProvisioning`] is a second such offer: given the tables an index
22//! reads ([`SourceSpec::all_tables`]), a source reports whether it can stream
23//! them and — when privileged — provisions the gap (for Postgres, a publication).
24//! Mechanism-neutral, so the daemon/CLI drive it without naming "publication".
25//!
26//! Both build on two shared, mechanism-neutral primitives that belong to
27//! neither concern:
28//!
29//! - [`RowKey`] — a row's primary key as ordered column/value pairs.
30//! - [`SnapshotTable`] — a schema-qualified table the engine asks a mechanism
31//!   to snapshot when seeding an index.
32//! - [`SourceSpec`] — the source's own view of what to build (the enabled
33//!   indexes and their schemas), a subset of the top-level config translated by
34//!   the composition root so the backend never sees `Config`.
35//! - [`SourceError`] / [`Result`] — the common error type.
36//!
37//! Keeping the two abstractions apart means a deployment can mix any change
38//! mechanism with any document builder, and either can be implemented, tested,
39//! or replaced without touching the other.
40
41mod error;
42mod provisioning;
43mod row_key;
44mod snapshot_table;
45mod spec;
46mod validation;
47
48pub mod cdc;
49pub mod document;
50
51pub use error::*;
52pub use provisioning::*;
53pub use row_key::*;
54pub use snapshot_table::*;
55pub use spec::*;
56pub use validation::*;