Class: Flydata::SourceMysql::PluginSupport::UnsupportedQueryHandler

Inherits:
TableDdlQueryHandler show all
Defined in:
lib/flydata/source_mysql/plugin_support/unsupported_query_handler.rb

Constant Summary collapse

PATTERN =

Catch all ddl

/.*/

Constants inherited from DdlQueryHandler

DdlQueryHandler::DDL_TABLE_QUERY

Constants included from PluginSupport::SyncRecordEmittable

PluginSupport::SyncRecordEmittable::RESPECT_ORDER, PluginSupport::SyncRecordEmittable::SEQ, PluginSupport::SyncRecordEmittable::SRC_POS, PluginSupport::SyncRecordEmittable::TABLE_NAME, PluginSupport::SyncRecordEmittable::TABLE_REV, PluginSupport::SyncRecordEmittable::TYPE, PluginSupport::SyncRecordEmittable::V

Instance Attribute Summary

Attributes included from PluginSupport::SyncRecordEmittable

#context

Instance Method Summary collapse

Methods inherited from DdlQueryHandler

#acceptable_db?, #emit_record, #table_info

Methods included from PluginSupport::SyncRecordEmittable

#emit_sync_records

Constructor Details

#initialize(context) ⇒ UnsupportedQueryHandler

Returns a new instance of UnsupportedQueryHandler.


11
12
13
# File 'lib/flydata/source_mysql/plugin_support/unsupported_query_handler.rb', line 11

def initialize(context)
  super
end

Instance Method Details

#patternObject


15
16
17
# File 'lib/flydata/source_mysql/plugin_support/unsupported_query_handler.rb', line 15

def pattern
  PATTERN
end

#process(record) ⇒ Object


19
20
21
22
23
24
# File 'lib/flydata/source_mysql/plugin_support/unsupported_query_handler.rb', line 19

def process(record)
  query = record['normalized_query']
  if acceptable_db?(record) && should_log?(query)
    $log.info({ type: :unsupported_query, query: query.to_s.strip}.to_s + " at \"#{binlog_pos(record)}\"")
  end
end

#should_log?(query) ⇒ Boolean

Returns:

  • (Boolean)

26
27
28
29
# File 'lib/flydata/source_mysql/plugin_support/unsupported_query_handler.rb', line 26

def should_log?(query)
  return false if query.to_s.empty?
  @context.tables.any?{|tbl| query.include?(tbl)}
end