Class: Ecco::SaveEventListener

Inherits:
EventListener show all
Defined in:
lib/ecco/save_event_listener.rb

Constant Summary collapse

SAVE_EVENTS =
[
  EventType::QUERY,
  EventType::ROTATE,
  EventType::WRITE_ROWS,
  EventType::UPDATE_ROWS,
  EventType::DELETE_ROWS,
]

Instance Attribute Summary

Attributes inherited from EventListener

#callback

Instance Method Summary collapse

Methods inherited from EventListener

#initialize

Constructor Details

This class inherits a constructor from Ecco::EventListener

Instance Method Details

#accepted_eventsObject



13
14
15
# File 'lib/ecco/save_event_listener.rb', line 13

def accepted_events
  SAVE_EVENTS
end

#on_event(event) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ecco/save_event_listener.rb', line 17

def on_event(event)
  type = event.get_header.get_event_type

  case type
  when *accepted_events
    filename = @client.get_binlog_filename
    position = @client.get_binlog_position

    @callback.call(filename, position)
  end
end