Skip to main content

Module mysql_io

Module mysql_io 

Source
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 BinlogStreamRequest from our config (for testing).
build_opts
Builds an OptsBuilder from 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 BinlogMessage type.
read_events
Reads binlog events from the stream with a timeout.
start_binlog_stream
Starts a binlog replication stream from the MySQL server.