Class: DBHandler

Inherits:
RethinkDB::Handler
  • Object
show all
Defined in:
lib/logstash/inputs/rethinkdb.rb

Overview

Handler for changes to the tables in a database

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db, plugin) ⇒ DBHandler

Returns a new instance of DBHandler.



216
217
218
219
220
# File 'lib/logstash/inputs/rethinkdb.rb', line 216

def initialize(db, plugin)
  super()
  @db = db
  @plugin = plugin
end

Instance Attribute Details

#dbObject

Returns the value of attribute db.



214
215
216
# File 'lib/logstash/inputs/rethinkdb.rb', line 214

def db
  @db
end

Instance Method Details

#on_change(old_val, new_val) ⇒ Object



244
245
246
247
# File 'lib/logstash/inputs/rethinkdb.rb', line 244

def on_change(old_val, new_val)
  @pluging.logger.log("Got table change #{old_val}, new: #{new_val}")
  @plugin.update_db_tables(old_val, new_val)
end

#on_change_error(err_str) ⇒ Object



235
236
237
# File 'lib/logstash/inputs/rethinkdb.rb', line 235

def on_change_error(err_str)
  @plugin.logger.warn(err_str)
end

#on_close(qhandle) ⇒ Object



226
227
228
# File 'lib/logstash/inputs/rethinkdb.rb', line 226

def on_close(qhandle)
  @plugin.unregister_db(@db)
end

#on_error(err, qhandle) ⇒ Object



230
231
232
233
# File 'lib/logstash/inputs/rethinkdb.rb', line 230

def on_error(err, qhandle)
  @plugin.logger.error(err.to_s)
  @plugin.unregister_db(@db)
end

#on_initial_val(val) ⇒ Object



239
240
241
242
# File 'lib/logstash/inputs/rethinkdb.rb', line 239

def on_initial_val(val)
  @plugin.logger.log("Initial val #{val}")
  @plugin.update_db_tables(nil, val)
end

#on_open(qhandle) ⇒ Object



222
223
224
# File 'lib/logstash/inputs/rethinkdb.rb', line 222

def on_open(qhandle)
  @plugin.register_db(@db, qhandle)
end