Expand description
MySQL CDC binlog I/O integration module.
This module provides the actual I/O operations for MySQL binlog replication
via the mysql_async crate. All functions are feature-gated behind mysql-cdc.
§Architecture
The I/O module is separate from the business logic in source.rs
to allow:
- Testing business logic without a running MySQL server
- Clean separation of concerns (connection management vs. event decoding)
- Easy mocking for unit tests
§Usage
ⓘ
use laminar_connectors::cdc::mysql::mysql_io;
let conn = mysql_io::connect(&config).await?;
let stream = mysql_io::start_binlog_stream(conn, &config, None, None).await?;
let events = mysql_io::read_events(&mut stream, 100, Duration::from_secs(1)).await?;
for event in events {
if let Some(msg) = mysql_io::decode_binlog_event(&event, &stream)? {
// Process BinlogMessage...
}
}Functions§
- build_
binlog_ request - Builds a
BinlogStreamRequestfrom our config (for testing). - build_
opts - Builds an
OptsBuilderfrom our config (for testing). - build_
ssl_ opts - Builds SSL options from our config.
- connect
- Connects to a MySQL server using the provided configuration.
- decode_
binlog_ event - Decodes a mysql_async binlog event into our internal
BinlogMessagetype. - read_
events - Reads binlog events from the stream with a timeout.
- start_
binlog_ stream - Starts a binlog replication stream from the MySQL server.