1
0
Fork 0
MySQL binary log parser
Go to file
Gregory Eremin f86864db3f Update docs 2020-07-28 00:12:19 +02:00
binlog Add ReadDecimal helper 2018-11-30 11:17:59 +01:00
buffer Add ReadDecimal helper 2018-11-30 11:17:59 +01:00
cmd Rename slave package to driver 2019-10-28 19:32:35 +01:00
mysql Update docs 2020-07-28 00:12:19 +02:00
reader Update docs 2020-07-28 00:12:19 +02:00
tests Rename slave package to driver 2019-10-28 19:32:35 +01:00
.gitignore Use dep to maintain dependencies 2018-11-09 01:09:25 +01:00
LICENCE Re-license and update readme 2019-10-28 20:41:19 +01:00
Makefile Use a separate make task to run tests verbose 2018-11-18 20:05:32 +01:00
README.md Update docs 2020-07-28 00:12:19 +02:00
go.mod Update docs 2020-07-28 00:12:19 +02:00
go.sum Migrate to go modules 2019-10-28 19:35:53 +01:00

README.md

Bocadillo

Bocadillo is a client for MySQL binary log. It is not a complete solution (yet).

Usage

Example use:

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

reader, err := reader.New("root@(127.0.0.1:3306)/testdb", driver.Config{
	ServerID: 1000,               // Arbitrary unique ID
	File:     "mysql-bin.000035", // Log file name
	Offset:   4,                  // Log file offset
})
if err != nil {
	log.Fatalf("Failed to connect: %v", err)
}

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)
	}
}

Caveats

This library is not a complete solution. It requires implementation that would involve everything from configuration to state management. Future releases might include pre-made binaries for certain message queue adapters.

Future development & contributions

The package in its current state does the job for me. Bug reports are welcome just like feature contributions.

Go MySQL driver modifications

Modified copy of go-sql-driver/mysql is included with this project. It was changed in order to expose certain low level functions that allow to establish a connection manually and register as a replica server and to remove automatic driver registration because it will likely conflict with the original code when imported as a dependency.

Licence

Mozilla Public License Version 2.0

This project includes a modified copy of go-sql-driver/mysql which is licensed under MPL-2.0, hence it should be licensed under the same lincense (or a GPL one).