Class: Fluent::FlydataMysqlBinlogQueryHandler

Inherits:
MysqlBinlogQueryHandler show all
Defined in:
lib/flydata/fluent-plugins/in_mysql_binlog_flydata.rb

Instance Method Summary collapse

Methods inherited from MysqlBinlogQueryHandler

#dispatch

Constructor Details

#initialize(opts) ⇒ FlydataMysqlBinlogQueryHandler

Returns a new instance of FlydataMysqlBinlogQueryHandler.



226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/flydata/fluent-plugins/in_mysql_binlog_flydata.rb', line 226

def initialize(opts)
  mandatory_opts = [:record_handler]
  missing_opts = mandatory_opts - opts.keys
  unless missing_opts.empty?
    raise "mandatory options are missing: #{missing_opts.join(", ")}"
  end
  @opts = opts

  @mapping_table = [
    [/^alter table/i, :on_alter_table],
  ]
end

Instance Method Details

#on_alter_table(record, query) ⇒ Object



239
240
241
242
243
244
245
246
# File 'lib/flydata/fluent-plugins/in_mysql_binlog_flydata.rb', line 239

def on_alter_table(record, query)
  m = /alter table\s+(?<table>[^\s]+)/i.match(query)
  if m.nil?
    raise "This alter table query has no table name? '#{query}'"
  end

  @opts[:record_handler].on_table_changed(m[:table])
end