1
0
Fork 0

Update readme

This commit is contained in:
Gregory Eremin 2018-11-11 16:13:33 +01:00
parent 4caf572811
commit 77a97a8020
1 changed files with 32 additions and 14 deletions

View File

@ -1,24 +1,42 @@
# BLT
# Bocadillo
MySQL binary log parser.
Bocadillo is a parser for MySQL binary log. It can connect to a server, register
as a slave and process binary log.
### Usage
```go
// import "github.com/localhots/bocadillo/reader"
reader, _ := reader.New("root@(127.0.0.1:3306)/testdb", slave.Config{
ServerID: 1000, // Arbitrary unique ID
File: "mysql-bin.000035", // Log file name
Offset: 4, // Log file offset
})
for {
evt, err := reader.ReadEvent()
if err != nil {
log.Fatalf("Failed to read event: %v", err)
}
log.Println("Event received:", evt.Header.Type.String())
if evt.Table != nil {
rows, err := evt.DecodeRows()
if err != nil {
log.Fatalf("Failed to parse rows event: %v", err)
}
log.Println("Table:", evt.Table.TableName, "Changes:", rows.Rows)
}
}
```
### WIP
Work in progress, some events are not fully supported.
A fork of [go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) is used
to provide underlying connection and basic packet exchange.
**TODO:**
* [x] FormatDescriptionEvent
* [x] TableMapEvent
* [x] RotateEvent
* [x] RowsEvent
* [ ] XIDEvent
* [ ] GTIDEvent
* [ ] QueryEvent
### Licence
MIT