[package]
name = "rivven-cdc"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
description = "Change Data Capture for Rivven - PostgreSQL, MySQL, MariaDB"
keywords = ["cdc", "postgres", "mysql", "mariadb", "replication"]

[package.metadata.cargo-machete]
# flate2: Required by mysql_async for compression support
ignored = ["flate2"]

[features]
default = ["postgres", "mysql"]
# PostgreSQL CDC via logical replication (pgoutput)
postgres = [
    "dep:tokio-postgres",
    "dep:postgres-protocol",
    "dep:md-5",
    "dep:hmac",
    "dep:pbkdf2",
    "dep:base64",
    "dep:fallible-iterator",
]
# PostgreSQL with TLS support (rustls-based)
postgres-tls = [
    "postgres",
    "dep:tokio-postgres-rustls",
    "dep:rustls",
    "dep:rustls-pemfile",
    "dep:webpki-roots",
    "dep:tokio-rustls",
]
# MySQL CDC via binary log replication
mysql = [
    "dep:sha1",
    "dep:base64",
    "dep:mysql_async",
    "dep:flate2",
]
# MySQL with TLS support (rustls-based)
mysql-tls = [
    "mysql",
    "dep:rustls",
    "dep:rustls-pemfile",
    "dep:webpki-roots",
    "dep:tokio-rustls",
]
# MariaDB CDC (uses MySQL binlog protocol with MariaDB extensions)
mariadb = ["mysql"]
# All CDC sources
full = ["postgres", "postgres-tls", "mysql", "mysql-tls", "mariadb"]

[dependencies]
tokio = { workspace = true }
futures = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
anyhow = { workspace = true }
tracing = { workspace = true }
bytes = { workspace = true }
chrono = { workspace = true }
url = { workspace = true }
async-trait = { workspace = true }
regex = "1.10"
once_cell = "1.19"
hex = "0.4"

# Metrics
metrics = { workspace = true }

# PostgreSQL-specific dependencies
tokio-postgres = { version = "0.7", features = ["with-chrono-0_4"], optional = true }
postgres-protocol = { version = "0.6", optional = true }
md-5 = { version = "0.10", optional = true }
fallible-iterator = { version = "0.2", optional = true }

# TLS support for PostgreSQL
tokio-postgres-rustls = { version = "0.13", optional = true }
rustls = { workspace = true, optional = true }
rustls-pemfile = { workspace = true, optional = true }
webpki-roots = { version = "0.26", optional = true }
tokio-rustls = { version = "0.26", optional = true }

# MySQL-specific dependencies
sha1 = { version = "0.10", optional = true }
base64 = { version = "0.22", optional = true }
mysql_async = { version = "0.34", optional = true, default-features = false }
# flate2 required by mysql_async for compression support
flate2 = { version = "1.1", optional = true, default-features = false, features = ["rust_backend"] }

# SCRAM authentication (PostgreSQL SCRAM-SHA-256)
hmac = { version = "0.12", optional = true }
pbkdf2 = { version = "0.12", optional = true }

# Encryption (AES-256-GCM for column-level encryption)
aes-gcm = "0.10"
# Ed25519 for MariaDB client_ed25519 authentication  
ed25519-dalek = { version = "2.1", features = ["rand_core"] }
# RSA for MySQL caching_sha2_password  
rsa = "0.9"
# Cryptographic RNG
rand = { workspace = true }
# SHA-256 hashing (for SMT hash operations)
sha2 = "0.10"

# Utilities
uuid = { workspace = true }
chrono-tz = "0.10"

[dev-dependencies]
rivven-core = { path = "../rivven-core" }
async-trait = "0.1"
uuid = { version = "1.6", features = ["v4"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
testcontainers = "0.23"
testcontainers-modules = { version = "0.11", features = ["postgres", "mysql", "mariadb"] }
pretty_assertions = "1.4"
criterion = { version = "0.5", features = ["async_tokio"] }
fake = { version = "3.0", features = ["derive", "chrono"] }
serial_test = "3.2"
tempfile = "3.10"
paste = "1.0"

[[test]]
name = "cdc_integration"
path = "tests/cdc_integration.rs"
required-features = ["postgres"]

[[test]]
name = "cdc_advanced"
path = "tests/cdc_advanced.rs"
required-features = ["postgres"]

[[test]]
name = "cdc_stress"
path = "tests/cdc_stress.rs"
required-features = ["postgres"]

[[test]]
name = "postgres_version_matrix"
path = "tests/postgres_version_matrix.rs"
required-features = ["postgres"]

[[test]]
name = "cdc_mysql_integration"
path = "tests/cdc_mysql_integration.rs"
required-features = ["mysql"]

[[test]]
name = "mysql_version_matrix"
path = "tests/mysql_version_matrix.rs"
required-features = ["mysql"]

[[bench]]
name = "cdc_throughput"
harness = false
required-features = ["postgres"]

[[bench]]
name = "cdc_latency"
harness = false
required-features = ["postgres"]
