rustcdc
rustcdc is an embeddable CDC library for Rust with a correctness-first design. The repository includes canonical event contracts, checkpoint safety primitives, schema history abstractions, an embedded runtime, and PostgreSQL/MySQL/MariaDB/SQL Server source connectors.
Status 🚀
Active development. Core connector/runtime library paths are implemented and validated by unit and integration suites.
Current crate release: 0.6.7.
MSRV 🛠️
This crate targets Rust 1.92 or newer, matching the rust-version declared in Cargo.toml.
Build 📦
Default profile enables postgres + tls. WASM transforms are opt-in (--features wasm).
Feature Profiles ⚙️
- default profile:
postgres+tls(lean, no JIT runtime in the default binary) --features wasm: WASM transform sandbox via wasmtime (~15 MB release binary overhead; opt-in by design)--features postgres: PostgreSQL connector profile (TLS transport is required and enabled transitively)--features mysql: MySQL connector profile (TLS transport is required and enabled transitively)--features mariadb: MariaDB connector profile (reuses the MySQL transport stack with MariaDB source identity)--features sqlserver: SQL Server connector profile (TLS transport is required and enabled transitively)--features tls: explicit TLS transport surface (already included by relational connector features)--features outbox: enables outbox helpers and transforms--features encryption: enables encryption-oriented transforms and helpers--features metrics: enables OpenTelemetry metrics/tracing integrations--no-default-features: foundation-only validation without source connectors--all-features: validates the full additive feature surface
For self-signed or private-CA deployments, configure TLS directly with TransportConfig::tls_with_ca_cert_path(...) or TransportConfig::mtls(...). No Cargo feature is required for those production-safe paths.
License
Licensed under either of:
- MIT license (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)
Run local quality checks:
Run full connector-backed evidence locally (requires Docker daemon):
To validate the foundation profile without source-specific features:
Benchmark Evidence Policy
Benchmark evidence is produced via scripts/ci-benchmark-gate.sh.
Local runs are allowed, but are classified as non-release evidence unless strict release-policy inputs are satisfied.
Example local run (non-release classification expected):
Release-grade benchmark classification now requires commit-pinned metadata plus a named Criterion baseline:
BENCHMARK_STRICT=1 \
BENCHMARK_MAX_REGRESSION_PERCENT=5 \
BENCHMARK_BASELINE_COMMIT="" \
BENCHMARK_BASELINE_ARTIFACT="BENCHMARK_REPORT.md" \
CRITERION_BASELINE="ci-baseline" \
Use the same CRITERION_BASELINE=ci-baseline value in CI so release evidence and local reports compare against the same named baseline.
Quick Start ✅
use ;
let checkpoint = default;
let schema_history = default;
let config = new;
let _config = config;
Delivery Guarantees 🔁
- Runtime delivery contract is at-least-once.
- Duplicate event delivery is possible after crashes, restart boundaries, and partial ack/commit windows.
- Ordering is preserved within committed ack prefixes, but consumers must still tolerate duplicates.
- Downstream systems should apply idempotency using stable keys (for example: source + table + primary key + source offset/transaction metadata).
Operational expectation:
- Treat rustcdc as correctness-first at-least-once transport, not exactly-once.
- Validate sink-side deduplication in staging before production rollout.
Runtime Transform Error Policy 🧯
RuntimeConfig defaults to halting on transform failures via TransformErrorPolicy::Halt.
For best-effort pipelines, switch to TransformErrorPolicy::Skip:
use ;
let checkpoint = default;
let schema_history = default;
let source = PostgresSourceConfig ;
let config = new
.with_transform_error_policy;
Halt is the safe default because it preserves strict failure visibility.
Post-Commit Confirmation Policy
RuntimeConfig now defaults to PostCommitSourceConfirmPolicy::FailFast.
If source confirmation fails after durable checkpoint commit, runtime returns an error by default to surface confirmation divergence immediately.
For availability-biased pipelines, opt into continue behavior explicitly:
use PostCommitSourceConfirmPolicy;
let config = config.with_post_commit_source_confirm_policy;
TRUNCATE Event Support
PostgreSQL TRUNCATE statements are surfaced as Operation::Truncate events. before and after are both None for truncate events. Connectors that support truncate events advertise ConnectorCapabilities::truncate.
Connection Retry 🔄
Configure ConnectionRetryPolicy for automatic reconnection on transient source failures:
use ConnectionRetryPolicy;
let config = config.with_connection_retry;
Only recoverable errors (SourceError, TimeoutError) trigger retry. Fatal errors propagate immediately.
Transport Configuration 🔒
All connectors default to TLS. For trusted private networks or local testing only, use the explicit plaintext escape hatch:
use TransportConfig;
let transport = plaintext; // ⚠️ never use in production
PostgreSQL Example 🐘
Build and run the PostgreSQL example:
The example also accepts environment variables (CDC_RS_HOST, CDC_RS_PORT, CDC_RS_DB, CDC_RS_SNAPSHOT_TABLES, and related settings) and commits every 100 events by default.
MariaDB Example 🐬
Build and run the MariaDB example:
The MariaDB example uses the same runtime loop as the PostgreSQL example, but it starts from MariaDbSourceConfig and a MariaDB-specific source identity.
Docker Compose Example 🐳
Bring up the local PostgreSQL + pg_to_stdout demo stack:
The compose setup initializes public.users and publication rustcdc_example_pub automatically.
Stop and clean up:
Documentation Map 📚
Operational Documentation
- Getting Started Guide - Setup and quick start
- Configuration Reference - Complete configuration options
- Troubleshooting Guide - Diagnosis and resolution procedures
- Operations Runbook - Production procedures, disaster recovery, alerting
- Documentation Index - Cross-referenced documentation map
Developer Documentation
- API Documentation - Rust SDK documentation
- Adapter SDK - Building custom adapters
- WASM Transform SDK - WASM transform runtime
Project Documentation
- Architecture: docs/architecture.md
- Library parity matrix (scope-aware release gating): docs/library_parity_matrix.md