reifydb_cdc/lib.rs
1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2025 ReifyDB
3
4//! Change Data Capture: durable record of every committed write, ordered, addressable, and consumable by external
5//! systems. The transaction layer hands committed deltas here at commit time; this crate persists them, exposes the
6//! consumer-side cursor APIs that downstream replication, subscriptions, and external sinks read from, and runs the
7//! background compactor that prunes records past retention.
8//!
9//! Producers and consumers are decoupled - a write only needs to be persisted before the transaction returns; the
10//! consumer side can fall arbitrarily far behind and catch up later. Storage is pluggable so the same protocol can
11//! be backed by SQLite for embedded deployments and by a horizontally scaled log for production.
12//!
13//! Invariant: a CDC record published for a transaction reflects exactly the deltas that were committed under that
14//! transaction id, in the order the engine produced them. Reordering or dropping deltas inside CDC desynchronises
15//! replicas and subscriptions from the source of truth.
16
17#![cfg_attr(not(debug_assertions), deny(clippy::disallowed_methods))]
18#![cfg_attr(debug_assertions, warn(clippy::disallowed_methods))]
19#![cfg_attr(not(debug_assertions), deny(warnings))]
20#![allow(clippy::tabs_in_doc_comments)]
21
22use reifydb_core::interface::version::{ComponentType, HasVersion, SystemVersion};
23
24#[cfg(all(feature = "sqlite", not(target_arch = "wasm32")))]
25pub mod compact;
26pub mod consume;
27pub mod error;
28pub mod produce;
29pub mod storage;
30pub mod testing;
31
32pub struct CdcVersion;
33
34impl HasVersion for CdcVersion {
35 fn version(&self) -> SystemVersion {
36 SystemVersion {
37 name: env!("CARGO_PKG_NAME")
38 .strip_prefix("reifydb-")
39 .unwrap_or(env!("CARGO_PKG_NAME"))
40 .to_string(),
41 version: env!("CARGO_PKG_VERSION").to_string(),
42 description: "Change Data Capture module".to_string(),
43 r#type: ComponentType::Module,
44 }
45 }
46}