Giter Club home page Giter Club logo

ecco's Introduction

Ecco

GitHub Build Status

MySQL (5.7 and 8.0) replication binlog parser using mysql-binlog-connector-java.

Installation

Add this line to your application's Gemfile:

gem "ecco"

And then execute:

$ bundle

Or install it yourself as:

$ gem install ecco

Usage

require "ecco"

hostname = "localhost" # Optional
port     = 3306        # Optional
username = "username"
password = "password"

client = Ecco::Client.new(hostname: hostname, port: port, username: username, password: password)

client.on_row_event do |row_event|
  type     = row_event.type
  database = row_event.database
  table    = row_event.table
  rows     = row_event.rows

  next unless database == "FooDatabase"
  next unless table == "FooTable"

  second_column = rows.first[1]

  puts "Row event: #{database} #{table} #{type} #{second_column}"
end

client.on_save_position do |filename, position, event_type_name|
  puts "Saved #{event_type_name} event: #{filename} #{position}"
end

client.on_communication_failure do |client, error|
  puts error.message
end

# Optionally set a starting position
client.set_binlog_filename("mysql-bin.000009")
client.set_binlog_position(276753)

client.start

Development

To download a new version of mysql-binlog-connector-java

bundle exec rake maven:dependencies

Note: You need Maven to download

brew install maven

Run the tests

bin/specs

For an interactive prompt

bin/console

To install this gem onto your local machine

bundle exec rake install

Integration tests

The integration tests don't run by default. To run all the tests, including integration, use

bin/all_specs

The tests needs a MySQL server with replication enabled.

Ecco includes multiple Docker Compose definitions that can be used for this, one per supported MySQL version.

Start the desired version before running the tests:

# MySQL 5.7
docker-compose -f docker-compose-mysql-base.yml -f docker-compose-mysql-5-7.yml up

# MySQL 8.0
docker-compose -f docker-compose-mysql-base.yml -f docker-compose-mysql-8-0.yml up

Note: Stop any local MySQL server first, otherwise there will be port collisions

Release

To release a new version, make a commit bumping the version number in version.rb, and then run

bundle exec rake release

which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Update the changelog with GitHub Changelog Generator:

github_changelog_generator

Preparations you might have to do:

  • gem install github_changelog_generator if you don't have it
  • set CHANGELOG_GITHUB_TOKEN to a personal access token to increase your GitHub API rate limit

Make a commit with the changelog changes and push.

License

The gem is available as open source under the terms of the Apache License, Version 2.0.

ecco's People

Contributors

walro avatar dentarg avatar roback avatar chrizpy avatar twingly-mob avatar jage avatar pontus4 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.