项目作者: localhots

项目描述 :
MySQL binary log parser
高级语言: Go
项目地址: git://github.com/localhots/bocadillo.git
创建时间: 2018-07-29T17:22:57Z
项目社区:https://github.com/localhots/bocadillo

开源协议:Mozilla Public License 2.0

下载


Bocadillo

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

Usage

Example use:

  1. // import "github.com/localhots/bocadillo/reader"
  2. // import "github.com/localhots/bocadillo/reader/driver"
  3. reader, err := reader.New("root@(127.0.0.1:3306)/testdb", driver.Config{
  4. ServerID: 1000, // Arbitrary unique ID
  5. File: "mysql-bin.000035", // Log file name
  6. Offset: 4, // Log file offset
  7. })
  8. if err != nil {
  9. log.Fatalf("Failed to connect: %v", err)
  10. }
  11. for {
  12. evt, err := reader.ReadEvent()
  13. if err != nil {
  14. log.Fatalf("Failed to read event: %v", err)
  15. }
  16. log.Println("Event received:", evt.Header.Type.String())
  17. if evt.Table != nil {
  18. rows, err := evt.DecodeRows()
  19. if err != nil {
  20. log.Fatalf("Failed to parse rows event: %v", err)
  21. }
  22. log.Println("Table:", evt.Table.TableName, "Changes:", rows.Rows)
  23. }
  24. }

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