Expand description
MySQL CDC conversion, committed transactions and checkpoint management.
use mysql_canal::{CommittedTransaction, Canal, Result, config::AppConfig};
use std::path::Path;
fn main() -> Result<()> {
let config = AppConfig::read(Path::new("canal.toml"))?;
let mut canal = Canal::new(config)?;
canal.add_handle(|event: CommittedTransaction<'_>| {
for change in event.changes {
println!("{} {:?} {:?}", event.source_id, change.operation, change.pk);
}
Ok(())
});
canal.run()
}Re-exports§
pub use engine::Canal;pub use error::Error;pub use error::Result;pub use error::RunError;pub use error::SourceFailure;pub use model::CdcImageMode;pub use model::Change;pub use model::ColumnMeta;pub use model::CommittedTransaction;pub use model::Field;pub use model::FieldImage;pub use model::Fields;pub use model::Operation;pub use model::OwnedChange;pub use model::OwnedFieldImage;pub use model::PrimaryKey;pub use model::TableMeta;pub use protocol::mysql::Decoder;pub use sink::TransactionHandler;
Modules§
- config
- engine
- Source orchestration, transaction visibility and checkpoint persistence.
- error
- model
- Typed change records, primary keys and ordered table metadata.
- protocol
- Database-specific wire protocols and version adapters.
- sink
- Transaction sink contract and output implementations.
- source
- Source plugin interfaces and registry; concrete transports live in submodules.
Structs§
- Decimal
Value - Exact packed DECIMAL, borrowing the validated wire bytes. Formatting preserves scale and never passes through floating point.
- Full
- Every existing image contains every table column.
- Integer
Value - A wire integer without an assumed SQL signedness. TABLE_MAP’s required metadata does not identify signed/unsigned columns.
- Minimal
- Sparse images preserve exactly the columns present in the log.
Enums§
- RowOperation
- An operation whose shape cannot contain missing required images.
- RowValue
- Protocol values, independent from a table whitelist or CDC primary key.