#![forbid(unsafe_code)]
use datum_cdc::{CdcSource, ChangeEvent, MemoryCheckpointStore, PostgresCdcConfig, SlotLifecycle};
#[test]
fn cdc_source_blueprint() {
use datum::Source;
use datum_cdc::{CdcHandle, CdcResult};
fn build_orders_source() -> CdcResult<Source<ChangeEvent, CdcHandle>> {
CdcSource::postgres()
.connect(PostgresCdcConfig::from_url(
"postgresql://datum_cdc@127.0.0.1:5432/datum_cdc?sslmode=disable",
)?)
.slot("datum_orders")
.publication("orders_pub")
.slot_lifecycle(SlotLifecycle::Existing)
.buffer_capacity(8192)
.build()
}
let source = build_orders_source().expect("CDC blueprint builds");
let _ = source;
}
#[test]
fn cdc_source_with_context_and_checkpoint_store() {
use datum::SourceWithContext;
use datum_cdc::{CdcHandle, CdcOffset};
let source: SourceWithContext<ChangeEvent, CdcOffset, CdcHandle> = CdcSource::postgres()
.connect(
PostgresCdcConfig::from_url("postgresql://datum_cdc@127.0.0.1:5432/datum_cdc")
.expect("valid url"),
)
.slot("datum_orders")
.publication("orders_pub")
.slot_lifecycle(SlotLifecycle::CreateIfMissing)
.checkpoint_store(MemoryCheckpointStore::new())
.build_with_context()
.expect("CDC context blueprint builds");
let _ = source;
}