Class: Fluent::FlydataMysqlBinlogRecordHandler

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

Constant Summary collapse

TABLE_NAME =

A Flydata JSON tag to specify a table name

'table_name'
TYPE =
'type'
ROW =
'row'
SEQ =
'seq'
RESPECT_ORDER =
'respect_order'
INTEGER_TYPES =
{'TINY' => 1,
 'SHORT' => 2,
 'INT24' => 3,
 'LONG' => 4,
 'LONGLONG' => 8
}
SIGNLESS_INTEGER_PREFIX =
'0SL'

Instance Method Summary collapse

Methods inherited from MysqlBinlogRecordHandler

#dispatch

Constructor Details

#initialize(opts) ⇒ FlydataMysqlBinlogRecordHandler

Returns a new instance of FlydataMysqlBinlogRecordHandler.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/flydata/fluent-plugins/in_mysql_binlog_flydata.rb', line 88

def initialize(opts)
  mandatory_opts = [:database, :tables, :tag, :sync_fm]

  missing_opts = mandatory_opts - opts.keys
  unless (missing_opts.empty?)
    raise "Mandatory option(s) are missing: #{missing_opts.join(', ')}"
  end
  @database = opts[:database]
  @tables = opts[:tables]
  @tag = opts[:tag]
  @sync_fm = opts[:sync_fm]

  @query_handler = FlydataMysqlBinlogQueryHandler.new(record_handler: self)
end

Instance Method Details

#on_delete_rows(record) ⇒ Object



111
112
113
# File 'lib/flydata/fluent-plugins/in_mysql_binlog_flydata.rb', line 111

def on_delete_rows(record)
  emit_delete(record)
end

#on_query(record) ⇒ Object



115
116
117
# File 'lib/flydata/fluent-plugins/in_mysql_binlog_flydata.rb', line 115

def on_query(record)
  @query_handler.dispatch(record)
end

#on_table_changed(table) ⇒ Object



119
120
121
# File 'lib/flydata/fluent-plugins/in_mysql_binlog_flydata.rb', line 119

def on_table_changed(table)
  $log.trace "Table #{table} has changed.  Reloading the table column"
end

#on_update_rows(record) ⇒ Object



107
108
109
# File 'lib/flydata/fluent-plugins/in_mysql_binlog_flydata.rb', line 107

def on_update_rows(record)
  emit_update(record)
end

#on_write_rows(record) ⇒ Object



103
104
105
# File 'lib/flydata/fluent-plugins/in_mysql_binlog_flydata.rb', line 103

def on_write_rows(record)
  emit_insert(record)
end