Sha256: 201780fd41da473dfc00ff2cae39cf6f23623886f59a132e82f0cab981f25cac
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
require "ext/mysql-binlog-connector-java-#{Ecco::MYSQL_BINLOG_CONNECTOR_VERSION}.jar" require "ecco/row_event_listener" require "ecco/save_event_listener" require "ecco/error" module Ecco class Client DEFAULT_CONNECT_TIMEOUT = 3000 # ms extend Forwardable def_delegators :@client, :set_server_id, :get_server_id def_delegators :@client, :set_binlog_filename, :get_binlog_filename def_delegators :@client, :set_binlog_position, :get_binlog_position java_import com.github.shyiko.mysql.binlog.BinaryLogClient java_import java.io.IOException def initialize(hostname: "localhost", port: 3306, username:, password:) @client = BinaryLogClient.new(hostname, port, username, password) @row_event_listener = RowEventListener.new(self) @client.register_event_listener(@row_event_listener) @save_event_listener = SaveEventListener.new(self) @client.register_event_listener(@save_event_listener) end def on_save_position(&block) @save_event_listener.callback = block end def on_row_event(&block) @row_event_listener.callback = block end def start @client.connect rescue IOException => e raise Ecco::Error::ConnectionError, e.get_message end def start_in_thread(connect_timeout: DEFAULT_CONNECT_TIMEOUT) @client.connect(connect_timeout) end def stop @client.disconnect end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ecco-0.4.1-java | lib/ecco/client.rb |