1
0
Fork 0
MySQL binary log parser
Go to file
Gregory Eremin f61e0d6e84 Use a separate make task to run tests verbose 2018-11-18 20:05:32 +01:00
binlog Remove debug 2018-11-14 16:04:09 +01:00
cmd Implement timeouts and graceful shutdown 2018-11-15 11:34:27 +01:00
mysql Format time per RFC 3339 2018-11-18 20:03:38 +01:00
reader Implement timeouts and graceful shutdown 2018-11-15 11:34:27 +01:00
tests Format time per RFC 3339 2018-11-18 20:03:38 +01:00
tools Remove debug 2018-11-14 16:04:09 +01:00
.gitignore Use dep to maintain dependencies 2018-11-09 01:09:25 +01:00
Gopkg.lock Add mysql driver to deps 2018-11-14 15:59:30 +01:00
Gopkg.toml Use dep to maintain dependencies 2018-11-09 01:09:25 +01:00
LICENCE Initial commit 2018-07-29 19:20:30 +02:00
Makefile Use a separate make task to run tests verbose 2018-11-18 20:05:32 +01:00
README.md Fix readme indentation 2018-11-11 16:17:41 +01:00

README.md

Bocadillo

Bocadillo is a parser for MySQL binary log. It can connect to a server, register as a slave and process binary log.

Usage

// import "github.com/localhots/bocadillo/reader"
// import "github.com/localhots/bocadillo/reader/slave"

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

This package is a work in progress and can't be considered production ready just yet.

A fork of go-sql-driver/mysql is used to provide underlying connection and basic packet exchange.

Licence

MIT