Giter Club home page Giter Club logo

bocadillo's Introduction

Bocadillo

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

Usage

Example use:

// import "github.com/Vivino/bocadillo/reader"
// import "github.com/Vivino/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).

bocadillo's People

Contributors

eikmadsen avatar glaslos avatar localhots avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.