https://github.com/groonga/mysql2-replication
binlog extension for mysql2 gem
https://github.com/groonga/mysql2-replication
Last synced: about 1 year ago
JSON representation
binlog extension for mysql2 gem
- Host: GitHub
- URL: https://github.com/groonga/mysql2-replication
- Owner: groonga
- License: mit
- Created: 2021-11-16T06:20:10.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-18T09:33:53.000Z (over 4 years ago)
- Last Synced: 2024-04-29T08:20:15.839Z (about 2 years ago)
- Language: C
- Size: 35.2 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# mysql2-replication
## Description
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.
## Install
```bash
gem install mysql2-replication
```
## Usage
```ruby
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.