Class: Mysql::DatabaseDdlQueryHandler

Inherits:
DdlQueryHandler show all
Defined in:
lib/flydata/fluent-plugins/mysql/ddl_query_handler.rb

Direct Known Subclasses

DropDatabaseQueryHandler

Constant Summary

Constants inherited from DdlQueryHandler

Mysql::DdlQueryHandler::DDL_TABLE_QUERY

Constants inherited from BinlogRecordHandler

BinlogRecordHandler::RESPECT_ORDER, BinlogRecordHandler::SEQ, BinlogRecordHandler::SRC_POS, BinlogRecordHandler::TABLE_NAME, BinlogRecordHandler::TABLE_REV, BinlogRecordHandler::TYPE, BinlogRecordHandler::V

Instance Method Summary collapse

Methods inherited from DdlQueryHandler

#acceptable_db?, #table_info

Methods inherited from BinlogQueryHandler

#pattern

Methods inherited from BinlogRecordHandler

#initialize

Constructor Details

This class inherits a constructor from Mysql::BinlogRecordHandler

Instance Method Details

#emit_record(type, record) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/flydata/fluent-plugins/mysql/ddl_query_handler.rb', line 32

def emit_record(type, record)
  return unless acceptable_db?(record)

  check_empty_binlog

  opt = {}
  records = yield(opt) # The block may set options as necessary
  return if records.nil? # skip
  records = [records] unless records.kind_of?(Array)

  database = records.first[DB_NAME] || record['db_name']

  return unless acceptable_event?(type)

  position = record['next_position'] - record['event_length']

  # Add common information to each record
  records.each do |r|
    r[TYPE] = type
    r[RESPECT_ORDER] = true
    r[SRC_POS] = "#{@context.current_binlog_file}\t#{position}"
    r[V] = FlydataCore::Record::V2
  end

  # Use binlog's timestamp
  timestamp = record["timestamp"].to_i
  records.each do |row|
    Fluent::Engine.emit(@context.tag, timestamp, row)
  end
end