mysql-replication
English | 简体中文
The bottom library in mysql-cdc: synchronous MySQL binlog subscription, protocol parsing and BinlogEvent generation. Raw insert/update/delete images can be decoded on demand; normalized CDC events, transaction delivery and checkpoints belong to mysql-canal.
Read a local binlog
To integrate from local source, use the dependency below; replace /path/to/mysql-cdc-rs with your checkout path.
[]
= { = "/path/to/mysql-cdc-rs/crates/mysql-replication" }
use ;
use ;
next_event() returns original bytes, the common header and an EventData body, borrowed until the next read. Use into_owned() only when retaining an event. Event::dump prints field diagnostics. Files must retain their initial FDE.
Subscribe to MySQL
use ;
Credentials come from MYSQL_URL. row_image validates the upstream setting without changing MySQL; callers supply the file and position. next_frame() returns a validated raw frame, while network next_view() borrows the driver body directly.
Fix the mode at construction
use ;
use ;
Minimal / Full propagate through parser, reader, BinlogEvent and RowsEvent. ReplicationStream::<Full>::for_mode(connection, config) validates type/config agreement before connecting. next_event() returns mode-checked events; raw next_frame() / next_view() remain unclassified. Default constructors use Unspecified.
Decode row images
Build a RowsDecoder from TABLE_MAP and iterate before/after images through RowsEvent::rows(&decoder). Minimal uses SparseImage; Full uses CompleteImage and rejects incomplete images. Raw decoding requires no primary key and provides no transaction buffering. Callers maintain, replace and clear TABLE_MAP plans.
Run examples from the workspace root. See the event reference for field definitions, NULL/absent-column distinctions and mode-specific accessors.