ecco 0.4.1-java → 0.8.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -1
- data/.travis.yml +22 -22
- data/CHANGELOG.md +87 -0
- data/README.md +33 -9
- data/Rakefile +2 -0
- data/docker-compose-mysql-5-6.yml +5 -0
- data/docker-compose-mysql-5-7.yml +5 -0
- data/docker-compose-mysql-8-0.yml +5 -0
- data/docker-compose-mysql-base.yml +13 -0
- data/{vagrant/files → docker}/ecco-my.cnf +0 -1
- data/ecco.gemspec +1 -1
- data/lib/ecco/client.rb +30 -0
- data/lib/ecco/error.rb +3 -0
- data/lib/ecco/lifecycle_failure_listener.rb +14 -0
- data/lib/ecco/row_event_listener.rb +19 -6
- data/lib/ecco/save_event_listener.rb +15 -11
- data/lib/ecco/version.rb +2 -2
- data/lib/ext/mysql-binlog-connector-java-0.21.0.jar +0 -0
- data/pom.xml +1 -1
- metadata +34 -31
- data/Vagrantfile +0 -11
- data/lib/ext/mysql-binlog-connector-java-0.2.4.jar +0 -0
- data/vagrant/playbook.yml +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: aa0f1adf6e5a97d969a6acf43b3ec6d083e7975e3e60f4684e46b672453dd7e1
|
4
|
+
data.tar.gz: de78c5aba80a3ff667d63408721723737e5ae731124c55f413b2c5f0fdb15f4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ee74c54f9ab18d42046b00e7e6e48b7de8c761482a1a5840945ff77bdd3c618ed81721987a6873f76d99dc99835a373c872e8eeba68ed480995a898b6c250e8
|
7
|
+
data.tar.gz: 56a14190b670b5a8e02cd1d200f9aab042c3a471287c07a0f80372230a068d90de7c5e80c108f062fe918f8ccf4d383cc48a00edc3d0da474d924424c5d0d0dc
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
dist: bionic
|
3
2
|
language: ruby
|
4
|
-
|
5
3
|
services:
|
6
|
-
-
|
4
|
+
- docker
|
5
|
+
|
6
|
+
addons:
|
7
|
+
apt:
|
8
|
+
packages:
|
9
|
+
- haveged # Extra entropy
|
7
10
|
|
8
11
|
before_install:
|
9
|
-
-
|
10
|
-
- rvm
|
11
|
-
-
|
12
|
-
-
|
13
|
-
-
|
14
|
-
-
|
12
|
+
- sudo service haveged start # Extra entropy to ensure quick start time for JRuby
|
13
|
+
- rvm get master
|
14
|
+
- rvm install jruby-9.2.13.0
|
15
|
+
- rvm use jruby-9.2.13.0
|
16
|
+
- gem install bundler -v '< 2'
|
17
|
+
- docker-compose -f docker-compose-mysql-base.yml -f docker-compose-mysql-$MYSQL_VERSION.yml up -d
|
15
18
|
|
16
19
|
env:
|
17
20
|
global:
|
18
|
-
-
|
19
|
-
|
20
|
-
-
|
21
|
+
- JRUBY_OPTS='--client -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-Xss2m -Xcompile.invokedynamic=false'
|
22
|
+
jobs:
|
23
|
+
- MYSQL_VERSION="5-6"
|
24
|
+
- MYSQL_VERSION="5-7"
|
25
|
+
- MYSQL_VERSION="8-0"
|
26
|
+
|
27
|
+
jobs:
|
28
|
+
allow_failures:
|
29
|
+
- env: MYSQL_VERSION="8-0"
|
21
30
|
|
22
31
|
script: bin/all_specs
|
23
32
|
|
24
33
|
notifications:
|
25
34
|
email: false
|
26
|
-
hipchat:
|
27
|
-
on_success: never
|
28
|
-
on_failure: change
|
29
|
-
template:
|
30
|
-
- '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}
|
31
|
-
(<a href="%{build_url}">Details</a>/<a href="%{compare_url}">Change view</a>)'
|
32
|
-
format: html
|
33
|
-
rooms:
|
34
|
-
secure: J7yYVGr6NQ0rOA6WdOVxiB4XxPJJDcQG7R0fgAXxtAzQNun+QHLBH9Yu7NN7kaJrVU69oIMrAw2e7EGSh9mnQ3fmGyA/z9Xu5+3GYjGuN3QDLGA8kbnDggIeo8vZrTZYL9aITVHMUH/6oKwAtg4Q5Tx4ftguj4zvMMWiZTFHuv05V0FgyoQkSggKLE3w8ZndEjZfaBbtgUeN/eGeAl2oeP8w53eM4ebh2+VNYNVGr+5zr1VGkkXz1SoRT3YEJtSjH0DvinZDrsU3VZZY9hIcUKu3dzhPuwZFMIDGshDxVqf/0XADOFUqgYFeHmg64O+ikIye4MiuBKw/miqSvx6lZSdjlsYyHruYFCbjcZue/WIKAw5nWZNQ+YZmzxMWZV4czImO8q2ljMOXUluVgW78mZMYsqzsoE5tX6PVO4I7aVL4L9mnb01nPDAPgJAXCGfudOkHfUi6jaVTkvLqSJvifbCzhsRvaPCA2VAQGUTssv9pm2YkCP5rOOeasU+XgJtLJif8Uv1g/zNjNajNU19A1PLCSNgdvX381Dgd3NS/DjMtNtgTXxGjSpHwQM54aL/lp6a2XhCpSpBZBcBz01KQJGsgLUgDDQJSzO1e8OdiP6YQHIGEA0OM4Wfoq2I3TLWMSlGSzJBvUBHJwstPMjTbH+1HM2AOY80orVHQWzttZlc=
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## [v0.7.0](https://github.com/twingly/ecco/tree/v0.7.0) (2016-10-07)
|
4
|
+
[Full Changelog](https://github.com/twingly/ecco/compare/v0.6.1...v0.7.0)
|
5
|
+
|
6
|
+
**Implemented enhancements:**
|
7
|
+
|
8
|
+
- Extend on\_save\_position with information about the event [\#23](https://github.com/twingly/ecco/issues/23)
|
9
|
+
|
10
|
+
**Merged pull requests:**
|
11
|
+
|
12
|
+
- Expose event information in on\_save\_position [\#24](https://github.com/twingly/ecco/pull/24) ([dentarg](https://github.com/dentarg))
|
13
|
+
- Add changelog [\#21](https://github.com/twingly/ecco/pull/21) ([dentarg](https://github.com/dentarg))
|
14
|
+
|
15
|
+
## [v0.6.1](https://github.com/twingly/ecco/tree/v0.6.1) (2016-07-18)
|
16
|
+
[Full Changelog](https://github.com/twingly/ecco/compare/v0.6.0...v0.6.1)
|
17
|
+
|
18
|
+
**Merged pull requests:**
|
19
|
+
|
20
|
+
- MySQL 5.6 support [\#20](https://github.com/twingly/ecco/pull/20) ([jage](https://github.com/jage))
|
21
|
+
- Use standard rvm key for jruby version [\#19](https://github.com/twingly/ecco/pull/19) ([walro](https://github.com/walro))
|
22
|
+
- Improve rake task description [\#17](https://github.com/twingly/ecco/pull/17) ([jage](https://github.com/jage))
|
23
|
+
|
24
|
+
## [v0.6.0](https://github.com/twingly/ecco/tree/v0.6.0) (2015-12-04)
|
25
|
+
[Full Changelog](https://github.com/twingly/ecco/compare/v0.5.0...v0.6.0)
|
26
|
+
|
27
|
+
**Closed issues:**
|
28
|
+
|
29
|
+
- Feature: Ecco::Client\#connected? [\#14](https://github.com/twingly/ecco/issues/14)
|
30
|
+
|
31
|
+
**Merged pull requests:**
|
32
|
+
|
33
|
+
- Implement Ecco::Client\#connected? [\#15](https://github.com/twingly/ecco/pull/15) ([jage](https://github.com/jage))
|
34
|
+
|
35
|
+
## [v0.5.0](https://github.com/twingly/ecco/tree/v0.5.0) (2015-11-26)
|
36
|
+
[Full Changelog](https://github.com/twingly/ecco/compare/v0.4.1...v0.5.0)
|
37
|
+
|
38
|
+
**Fixed bugs:**
|
39
|
+
|
40
|
+
- Trying to connect to non-existent position behaves strange? [\#8](https://github.com/twingly/ecco/issues/8)
|
41
|
+
|
42
|
+
**Merged pull requests:**
|
43
|
+
|
44
|
+
- Add keep alive getters and setters [\#11](https://github.com/twingly/ecco/pull/11) ([dentarg](https://github.com/dentarg))
|
45
|
+
- Helper method for java root logger [\#10](https://github.com/twingly/ecco/pull/10) ([dentarg](https://github.com/dentarg))
|
46
|
+
- Add \#on\_communication\_failure [\#9](https://github.com/twingly/ecco/pull/9) ([walro](https://github.com/walro))
|
47
|
+
|
48
|
+
## [v0.4.1](https://github.com/twingly/ecco/tree/v0.4.1) (2015-11-19)
|
49
|
+
[Full Changelog](https://github.com/twingly/ecco/compare/v0.4.0...v0.4.1)
|
50
|
+
|
51
|
+
**Implemented enhancements:**
|
52
|
+
|
53
|
+
- Ensure that we handle "on\_row\_event" before "on\_save\_position" [\#5](https://github.com/twingly/ecco/issues/5)
|
54
|
+
|
55
|
+
**Merged pull requests:**
|
56
|
+
|
57
|
+
- Make sure row\_event happens before save\_event [\#7](https://github.com/twingly/ecco/pull/7) ([roback](https://github.com/roback))
|
58
|
+
- Minor refactoring [\#6](https://github.com/twingly/ecco/pull/6) ([dentarg](https://github.com/dentarg))
|
59
|
+
|
60
|
+
## [v0.4.0](https://github.com/twingly/ecco/tree/v0.4.0) (2015-11-18)
|
61
|
+
[Full Changelog](https://github.com/twingly/ecco/compare/v0.3.1...v0.4.0)
|
62
|
+
|
63
|
+
**Implemented enhancements:**
|
64
|
+
|
65
|
+
- Integration tests [\#2](https://github.com/twingly/ecco/issues/2)
|
66
|
+
|
67
|
+
**Merged pull requests:**
|
68
|
+
|
69
|
+
- Add integration tests [\#3](https://github.com/twingly/ecco/pull/3) ([roback](https://github.com/roback))
|
70
|
+
|
71
|
+
## [v0.3.1](https://github.com/twingly/ecco/tree/v0.3.1) (2015-11-09)
|
72
|
+
[Full Changelog](https://github.com/twingly/ecco/compare/v0.3.0...v0.3.1)
|
73
|
+
|
74
|
+
## [v0.3.0](https://github.com/twingly/ecco/tree/v0.3.0) (2015-11-09)
|
75
|
+
[Full Changelog](https://github.com/twingly/ecco/compare/v0.2.0...v0.3.0)
|
76
|
+
|
77
|
+
**Merged pull requests:**
|
78
|
+
|
79
|
+
- Implement basic functionality [\#1](https://github.com/twingly/ecco/pull/1) ([walro](https://github.com/walro))
|
80
|
+
|
81
|
+
## [v0.2.0](https://github.com/twingly/ecco/tree/v0.2.0) (2015-10-27)
|
82
|
+
[Full Changelog](https://github.com/twingly/ecco/compare/v0.1.0...v0.2.0)
|
83
|
+
|
84
|
+
## [v0.1.0](https://github.com/twingly/ecco/tree/v0.1.0) (2015-10-27)
|
85
|
+
|
86
|
+
|
87
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/twingly/ecco.svg?branch=master)](https://travis-ci.org/twingly/ecco)
|
4
4
|
|
5
|
-
MySQL replication binlog parser using [mysql-binlog-connector-java].
|
5
|
+
MySQL (5.6 and 5.7) replication binlog parser using [mysql-binlog-connector-java].
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -46,8 +46,12 @@ client.on_row_event do |row_event|
|
|
46
46
|
puts "Row event: #{database} #{table} #{type} #{second_column}"
|
47
47
|
end
|
48
48
|
|
49
|
-
client.on_save_position do |filename, position|
|
50
|
-
puts "
|
49
|
+
client.on_save_position do |filename, position, event_type_name|
|
50
|
+
puts "Saved #{event_type_name} event: #{filename} #{position}"
|
51
|
+
end
|
52
|
+
|
53
|
+
client.on_communication_failure do |client, error|
|
54
|
+
puts error.message
|
51
55
|
end
|
52
56
|
|
53
57
|
# Optionally set a starting position
|
@@ -87,25 +91,45 @@ The integration tests don't run by default. To run all the tests, including inte
|
|
87
91
|
|
88
92
|
The tests needs a MySQL server with replication enabled.
|
89
93
|
|
90
|
-
Ecco includes
|
94
|
+
Ecco includes multiple Docker Compose definitions that can be used for this, one per supported MySQL version.
|
95
|
+
|
96
|
+
Start the desired version before running the tests:
|
91
97
|
|
92
|
-
|
98
|
+
```shell
|
99
|
+
# MySQL 5.6
|
100
|
+
docker-compose -f docker-compose-mysql-base.yml -f docker-compose-mysql-5-6.yml up
|
93
101
|
|
94
|
-
|
102
|
+
# MySQL 5.7
|
103
|
+
docker-compose -f docker-compose-mysql-base.yml -f docker-compose-mysql-5-7.yml up
|
104
|
+
|
105
|
+
# MySQL 8.0
|
106
|
+
docker-compose -f docker-compose-mysql-base.yml -f docker-compose-mysql-8-0.yml up
|
107
|
+
```
|
95
108
|
|
96
|
-
*Note: Stop any local
|
109
|
+
*Note: Stop any local MySQL server first, otherwise there will be port collisions*
|
97
110
|
|
98
111
|
## Release
|
99
112
|
|
100
|
-
To release a new version,
|
113
|
+
To release a new version, make a commit bumping the version number in `version.rb`, and then run
|
101
114
|
|
102
115
|
bundle exec rake release
|
103
116
|
|
104
117
|
which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
105
118
|
|
119
|
+
Update the changelog with [GitHub Changelog Generator]:
|
120
|
+
|
121
|
+
github_changelog_generator
|
122
|
+
|
123
|
+
Preparations you might have to do:
|
124
|
+
|
125
|
+
* `gem install github_changelog_generator` if you don't have it
|
126
|
+
* set `CHANGELOG_GITHUB_TOKEN` to a personal access token to increase your GitHub API rate limit
|
127
|
+
|
128
|
+
Make a commit with the changelog changes and push.
|
129
|
+
|
106
130
|
## License
|
107
131
|
|
108
132
|
The gem is available as open source under the terms of the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
|
109
133
|
|
110
134
|
[mysql-binlog-connector-java]: https://github.com/shyiko/mysql-binlog-connector-java
|
111
|
-
[
|
135
|
+
[GitHub Changelog Generator]: https://github.com/skywinder/github-changelog-generator/
|
data/Rakefile
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
3
|
|
4
|
+
desc "Run non-integration specs"
|
4
5
|
RSpec::Core::RakeTask.new(:spec) do |task|
|
5
6
|
task.exclude_pattern = "spec/integration/*_spec.rb"
|
6
7
|
end
|
7
8
|
|
8
9
|
namespace :spec do
|
10
|
+
desc "Run all specs (including integration)"
|
9
11
|
RSpec::Core::RakeTask.new(:all)
|
10
12
|
end
|
11
13
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# https://docs.docker.com/compose/extends/#adding-and-overriding-configuration
|
2
|
+
|
3
|
+
version: "3.7"
|
4
|
+
|
5
|
+
services:
|
6
|
+
db:
|
7
|
+
volumes:
|
8
|
+
- ./docker/ecco-my.cnf:/etc/mysql/conf.d/ecco-my.cnf
|
9
|
+
ports:
|
10
|
+
- 3306:3306
|
11
|
+
environment:
|
12
|
+
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
|
13
|
+
MYSQL_DATABASE: ecco_test
|
data/ecco.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
-
spec.add_development_dependency "rake", "~>
|
23
|
+
spec.add_development_dependency "rake", "~> 12"
|
24
24
|
spec.add_development_dependency "rspec"
|
25
25
|
spec.add_development_dependency "sequel"
|
26
26
|
spec.add_development_dependency "jdbc-mysql"
|
data/lib/ecco/client.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "ext/mysql-binlog-connector-java-#{Ecco::MYSQL_BINLOG_CONNECTOR_VERSION}.jar"
|
2
2
|
require "ecco/row_event_listener"
|
3
3
|
require "ecco/save_event_listener"
|
4
|
+
require "ecco/lifecycle_failure_listener"
|
4
5
|
require "ecco/error"
|
5
6
|
|
6
7
|
module Ecco
|
@@ -9,9 +10,27 @@ module Ecco
|
|
9
10
|
|
10
11
|
extend Forwardable
|
11
12
|
def_delegators :@client, :set_server_id, :get_server_id
|
13
|
+
def_delegators :@client, :set_keep_alive, :is_keep_alive
|
14
|
+
def_delegators :@client, :set_keep_alive_interval, :get_keep_alive_interval
|
15
|
+
def_delegators :@client, :set_heartbeat_interval, :get_heartbeat_interval
|
16
|
+
def_delegators :@client, :set_connect_timeout, :get_connect_timeout
|
12
17
|
def_delegators :@client, :set_binlog_filename, :get_binlog_filename
|
13
18
|
def_delegators :@client, :set_binlog_position, :get_binlog_position
|
14
19
|
|
20
|
+
def get_keep_alive_connect_timeout
|
21
|
+
warn "[DEPRECATION] `#{__method__}` is deprecated. "\
|
22
|
+
"Please use `get_connect_timeout` instead."
|
23
|
+
|
24
|
+
get_connect_timeout
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_keep_alive_connect_timeout(timeout)
|
28
|
+
warn "[DEPRECATION] `#{__method__}` is deprecated. "\
|
29
|
+
"Please use `set_connect_timeout` instead."
|
30
|
+
|
31
|
+
set_connect_timeout(timeout)
|
32
|
+
end
|
33
|
+
|
15
34
|
java_import com.github.shyiko.mysql.binlog.BinaryLogClient
|
16
35
|
java_import java.io.IOException
|
17
36
|
|
@@ -23,6 +42,9 @@ module Ecco
|
|
23
42
|
|
24
43
|
@save_event_listener = SaveEventListener.new(self)
|
25
44
|
@client.register_event_listener(@save_event_listener)
|
45
|
+
|
46
|
+
@lifecycle_failure_listener = LifecycleFailureListener.new
|
47
|
+
@client.register_lifecycle_listener(@lifecycle_failure_listener)
|
26
48
|
end
|
27
49
|
|
28
50
|
def on_save_position(&block)
|
@@ -33,6 +55,10 @@ module Ecco
|
|
33
55
|
@row_event_listener.callback = block
|
34
56
|
end
|
35
57
|
|
58
|
+
def on_communication_failure(&block)
|
59
|
+
@lifecycle_failure_listener.callback = block
|
60
|
+
end
|
61
|
+
|
36
62
|
def start
|
37
63
|
@client.connect
|
38
64
|
rescue IOException => e
|
@@ -43,6 +69,10 @@ module Ecco
|
|
43
69
|
@client.connect(connect_timeout)
|
44
70
|
end
|
45
71
|
|
72
|
+
def connected?
|
73
|
+
@client.is_connected
|
74
|
+
end
|
75
|
+
|
46
76
|
def stop
|
47
77
|
@client.disconnect
|
48
78
|
end
|
data/lib/ecco/error.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ecco
|
2
|
+
class LifecycleFailureListener < com.github.shyiko.mysql.binlog.BinaryLogClient::AbstractLifecycleListener
|
3
|
+
attr_writer :callback
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@callback = Proc.new {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def onCommunicationFailure(client, exception)
|
10
|
+
error = Ecco::Error::CommunicationError.new(exception.get_message)
|
11
|
+
@callback.call(client, error)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -3,11 +3,12 @@ require "ecco/row_event"
|
|
3
3
|
|
4
4
|
module Ecco
|
5
5
|
class RowEventListener < EventListener
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
# MySQL v1 and v2 row events
|
7
|
+
WRITE_EVENTS = [EventType::WRITE_ROWS, EventType::EXT_WRITE_ROWS]
|
8
|
+
UPDATE_EVENTS = [EventType::UPDATE_ROWS, EventType::EXT_UPDATE_ROWS]
|
9
|
+
DELETE_EVENTS = [EventType::DELETE_ROWS, EventType::EXT_DELETE_ROWS]
|
10
|
+
|
11
|
+
ROW_EVENTS = WRITE_EVENTS + UPDATE_EVENTS + DELETE_EVENTS
|
11
12
|
|
12
13
|
def table_event
|
13
14
|
EventType::TABLE_MAP
|
@@ -26,9 +27,9 @@ module Ecco
|
|
26
27
|
@table_map_event = event
|
27
28
|
when *accepted_events
|
28
29
|
row_event = Ecco::RowEvent.new
|
29
|
-
row_event.type = type.to_s
|
30
30
|
row_event.table_id = data.get_table_id
|
31
31
|
row_event.rows = data.rows
|
32
|
+
row_event.type = row_type_to_string(type)
|
32
33
|
|
33
34
|
if @table_map_event
|
34
35
|
table_event_data = @table_map_event.get_data
|
@@ -40,5 +41,17 @@ module Ecco
|
|
40
41
|
@callback.call(row_event)
|
41
42
|
end
|
42
43
|
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def row_type_to_string(type)
|
48
|
+
if WRITE_EVENTS.include?(type)
|
49
|
+
"WRITE_ROWS"
|
50
|
+
elsif UPDATE_EVENTS.include?(type)
|
51
|
+
"UPDATE_ROWS"
|
52
|
+
elsif DELETE_EVENTS.include?(type)
|
53
|
+
"DELETE_ROWS"
|
54
|
+
end
|
55
|
+
end
|
43
56
|
end
|
44
57
|
end
|
@@ -2,16 +2,19 @@ require "ecco/event_listener"
|
|
2
2
|
|
3
3
|
module Ecco
|
4
4
|
class SaveEventListener < EventListener
|
5
|
-
SAVE_EVENTS =
|
6
|
-
EventType::QUERY,
|
7
|
-
EventType::ROTATE,
|
8
|
-
EventType::WRITE_ROWS,
|
9
|
-
EventType::
|
10
|
-
EventType::
|
11
|
-
|
5
|
+
SAVE_EVENTS = {
|
6
|
+
EventType::QUERY => "QUERY",
|
7
|
+
EventType::ROTATE => "ROTATE",
|
8
|
+
EventType::WRITE_ROWS => "WRITE_ROWS",
|
9
|
+
EventType::EXT_WRITE_ROWS => "WRITE_ROWS",
|
10
|
+
EventType::UPDATE_ROWS => "UPDATE_ROWS",
|
11
|
+
EventType::EXT_UPDATE_ROWS => "UPDATE_ROWS",
|
12
|
+
EventType::DELETE_ROWS => "DELETE_ROWS",
|
13
|
+
EventType::EXT_DELETE_ROWS => "DELETE_ROWS",
|
14
|
+
}
|
12
15
|
|
13
16
|
def accepted_events
|
14
|
-
SAVE_EVENTS
|
17
|
+
SAVE_EVENTS.keys
|
15
18
|
end
|
16
19
|
|
17
20
|
def on_event(event)
|
@@ -19,10 +22,11 @@ module Ecco
|
|
19
22
|
|
20
23
|
case type
|
21
24
|
when *accepted_events
|
22
|
-
filename
|
23
|
-
position
|
25
|
+
filename = @client.get_binlog_filename
|
26
|
+
position = @client.get_binlog_position
|
27
|
+
event_type_name = SAVE_EVENTS.fetch(type)
|
24
28
|
|
25
|
-
@callback.call(filename, position)
|
29
|
+
@callback.call(filename, position, event_type_name)
|
26
30
|
end
|
27
31
|
end
|
28
32
|
end
|
data/lib/ecco/version.rb
CHANGED
Binary file
|
data/pom.xml
CHANGED
metadata
CHANGED
@@ -1,85 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Twingly AB
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
version_requirements: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.10'
|
20
14
|
requirement: !ruby/object:Gem::Requirement
|
21
15
|
requirements:
|
22
16
|
- - "~>"
|
23
17
|
- !ruby/object:Gem::Version
|
24
18
|
version: '1.10'
|
25
|
-
|
19
|
+
name: bundler
|
26
20
|
type: :development
|
27
|
-
|
28
|
-
name: rake
|
21
|
+
prerelease: false
|
29
22
|
version_requirements: !ruby/object:Gem::Requirement
|
30
23
|
requirements:
|
31
24
|
- - "~>"
|
32
25
|
- !ruby/object:Gem::Version
|
33
|
-
version: '10
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
34
28
|
requirement: !ruby/object:Gem::Requirement
|
35
29
|
requirements:
|
36
30
|
- - "~>"
|
37
31
|
- !ruby/object:Gem::Version
|
38
|
-
version: '
|
39
|
-
|
32
|
+
version: '12'
|
33
|
+
name: rake
|
40
34
|
type: :development
|
41
|
-
|
42
|
-
name: rspec
|
35
|
+
prerelease: false
|
43
36
|
version_requirements: !ruby/object:Gem::Requirement
|
44
37
|
requirements:
|
45
|
-
- - "
|
38
|
+
- - "~>"
|
46
39
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
40
|
+
version: '12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
48
42
|
requirement: !ruby/object:Gem::Requirement
|
49
43
|
requirements:
|
50
44
|
- - ">="
|
51
45
|
- !ruby/object:Gem::Version
|
52
46
|
version: '0'
|
53
|
-
|
47
|
+
name: rspec
|
54
48
|
type: :development
|
55
|
-
|
56
|
-
name: sequel
|
49
|
+
prerelease: false
|
57
50
|
version_requirements: !ruby/object:Gem::Requirement
|
58
51
|
requirements:
|
59
52
|
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
62
56
|
requirement: !ruby/object:Gem::Requirement
|
63
57
|
requirements:
|
64
58
|
- - ">="
|
65
59
|
- !ruby/object:Gem::Version
|
66
60
|
version: '0'
|
67
|
-
|
61
|
+
name: sequel
|
68
62
|
type: :development
|
69
|
-
|
70
|
-
name: jdbc-mysql
|
63
|
+
prerelease: false
|
71
64
|
version_requirements: !ruby/object:Gem::Requirement
|
72
65
|
requirements:
|
73
66
|
- - ">="
|
74
67
|
- !ruby/object:Gem::Version
|
75
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
76
70
|
requirement: !ruby/object:Gem::Requirement
|
77
71
|
requirements:
|
78
72
|
- - ">="
|
79
73
|
- !ruby/object:Gem::Version
|
80
74
|
version: '0'
|
81
|
-
|
75
|
+
name: jdbc-mysql
|
82
76
|
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
83
|
description: MySQL replication binlog parser using mysql-binlog-connector-java.
|
84
84
|
email:
|
85
85
|
- support@twingly.com
|
@@ -91,26 +91,30 @@ files:
|
|
91
91
|
- ".rspec"
|
92
92
|
- ".ruby-version"
|
93
93
|
- ".travis.yml"
|
94
|
+
- CHANGELOG.md
|
94
95
|
- Gemfile
|
95
96
|
- README.md
|
96
97
|
- Rakefile
|
97
|
-
- Vagrantfile
|
98
98
|
- bin/all_specs
|
99
99
|
- bin/console
|
100
100
|
- bin/specs
|
101
|
+
- docker-compose-mysql-5-6.yml
|
102
|
+
- docker-compose-mysql-5-7.yml
|
103
|
+
- docker-compose-mysql-8-0.yml
|
104
|
+
- docker-compose-mysql-base.yml
|
105
|
+
- docker/ecco-my.cnf
|
101
106
|
- ecco.gemspec
|
102
107
|
- lib/ecco.rb
|
103
108
|
- lib/ecco/client.rb
|
104
109
|
- lib/ecco/error.rb
|
105
110
|
- lib/ecco/event_listener.rb
|
111
|
+
- lib/ecco/lifecycle_failure_listener.rb
|
106
112
|
- lib/ecco/row_event.rb
|
107
113
|
- lib/ecco/row_event_listener.rb
|
108
114
|
- lib/ecco/save_event_listener.rb
|
109
115
|
- lib/ecco/version.rb
|
110
|
-
- lib/ext/mysql-binlog-connector-java-0.
|
116
|
+
- lib/ext/mysql-binlog-connector-java-0.21.0.jar
|
111
117
|
- pom.xml
|
112
|
-
- vagrant/files/ecco-my.cnf
|
113
|
-
- vagrant/playbook.yml
|
114
118
|
homepage: https://github.com/twingly/ecco
|
115
119
|
licenses:
|
116
120
|
- Apache-2.0
|
@@ -130,8 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
134
|
- !ruby/object:Gem::Version
|
131
135
|
version: '0'
|
132
136
|
requirements: []
|
133
|
-
|
134
|
-
rubygems_version: 2.4.8
|
137
|
+
rubygems_version: 3.0.6
|
135
138
|
signing_key:
|
136
139
|
specification_version: 4
|
137
140
|
summary: MySQL replication binlog parser.
|
data/Vagrantfile
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
Vagrant.configure("2") do |config|
|
2
|
-
config.vm.define "ecco-test" do |ubuntu|
|
3
|
-
ubuntu.vm.hostname = "ecco-test"
|
4
|
-
ubuntu.vm.box = "ubuntu/trusty64"
|
5
|
-
ubuntu.vm.provision :ansible do |ansible|
|
6
|
-
ansible.playbook = "vagrant/playbook.yml"
|
7
|
-
end
|
8
|
-
|
9
|
-
ubuntu.vm.network :forwarded_port, host: 3306, guest: 3306
|
10
|
-
end
|
11
|
-
end
|
Binary file
|
data/vagrant/playbook.yml
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- hosts: all
|
3
|
-
sudo: yes
|
4
|
-
tasks:
|
5
|
-
|
6
|
-
- name: Update package cache
|
7
|
-
apt: update_cache=yes
|
8
|
-
|
9
|
-
- name: Install ansible dependencies
|
10
|
-
apt: name={{ item }}
|
11
|
-
with_items:
|
12
|
-
- python-mysqldb
|
13
|
-
|
14
|
-
- name: Install mysql server
|
15
|
-
apt: name=mysql-server state=present
|
16
|
-
|
17
|
-
- name: Copy mysql config file
|
18
|
-
copy: src=files/ecco-my.cnf dest=/etc/mysql/conf.d/
|
19
|
-
|
20
|
-
- name: Allow mysql root connection from remote hosts
|
21
|
-
mysql_user: name=root password="" host=% priv=*.*:ALL state=present
|
22
|
-
|
23
|
-
- name: Restart mysql
|
24
|
-
service: name=mysql state=restarted
|
25
|
-
|
26
|
-
- name: Create database
|
27
|
-
mysql_db: name=ecco_test
|