scylla_cdc/lib.rs
1//! Async library for consuming [Scylla Change Data Capture](https://docs.scylladb.com/using-scylla/cdc/) log,
2//! built on top of the [Scylla Rust Driver](https://docs.rs/scylla/latest/scylla/).
3//!
4//! # Why use a library?
5//! The CDC log format is too complicated to be conveniently used in its raw form.
6//! The library enables the user to ignore the intricacies of the log's internal structure and concentrate on the business logic.
7//!
8//! # Other documentation
9//! * [Documentation of Scylla Rust Driver](https://docs.rs/scylla/latest/scylla/)
10//! * [Scylla documentation](https://docs.scylladb.com)
11//! * [Cassandra® documentation](https://cassandra.apache.org/doc/latest/)
12//! * [CDC documentation](https://docs.scylladb.com/using-scylla/cdc/)
13//!
14//! # Getting started
15//! The following code will start reading the CDC log from now until forever and will print type of every operation read.
16//! To learn in more detail about how to use the library, please refer to the [tutorial](https://github.com/scylladb/scylla-cdc-rust/blob/main/tutorial.md).
17//! ```rust,no_run
18//! use async_trait::async_trait;
19//! use scylla::client::session_builder::SessionBuilder;
20//! use scylla_cdc::consumer::*;
21//! use scylla_cdc::log_reader::CDCLogReaderBuilder;
22//! use std::sync::Arc;
23//!
24//! struct TypePrinterConsumer;
25//!
26//! #[async_trait]
27//! impl Consumer for TypePrinterConsumer {
28//! async fn consume_cdc(&mut self, data: CDCRow<'_>) -> anyhow::Result<()> {
29//! println!("{}", data.operation);
30//! Ok(())
31//! }
32//! }
33//!
34//! struct TypePrinterConsumerFactory;
35//!
36//! #[async_trait]
37//! impl ConsumerFactory for TypePrinterConsumerFactory {
38//! async fn new_consumer(&self) -> Box<dyn Consumer> {
39//! Box::new(TypePrinterConsumer)
40//! }
41//! }
42//!
43//! #[tokio::main]
44//! async fn main() -> anyhow::Result<()> {
45//! let session = Arc::new(
46//! SessionBuilder::new()
47//! .known_node("172.17.0.2:9042")
48//! .build()
49//! .await?,
50//! );
51//!
52//! let factory = Arc::new(TypePrinterConsumerFactory);
53//!
54//! let (_, handle) = CDCLogReaderBuilder::new()
55//! .session(session)
56//! .keyspace("ks")
57//! .table_name("t")
58//! .consumer_factory(factory)
59//! .build()
60//! .await
61//! .expect("Creating the log reader failed!");
62//!
63//! handle.await
64//! }
65//! ```
66
67pub mod cdc_types;
68pub mod checkpoints;
69pub mod consumer;
70mod e2e_tests;
71pub mod log_reader;
72mod stream_generations;
73mod stream_reader;