No commit activity in last 3 years
No release in over 3 years
mysql2-replication is an extension of [mysql2 gem](https://rubygems.org/gems/mysql2). It adds support for replication client feature based on `libmariadb.so` that is a MySQL/MariaDB client library provided by MariaDB.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

mysql2-replication

Description

mysql2-replication is an extension of mysql2 gem. It adds support for replication client feature based on libmariadb.so that is a MySQL/MariaDB client library provided by MariaDB.

Install

gem install mysql2-replication

Usage

require "mysql2-replication"

client = Mysql2::Client.new(username: "root",
                            password: "secret")
# Get the latest binlog file and position from source.
# You can specify them manually.
master_status = client.query("SHOW MASTER STATUS").first
file = master_status["File"]
position = master_status["Position"]

replication_client = Mysql2Replication::Client(client)
replication_client.file_name = file
replication_client.start_position = position
replication_client.open do
  replication_client.each do |event|
    pp event
  end
end

License

The MIT license. See LICENSE.txt for details.