Class: LogStash::PluginMixins::Jdbc::NormalStatementHandler

Inherits:
StatementHandler show all
Defined in:
lib/logstash/plugin_mixins/jdbc/statement_handler.rb

Direct Known Subclasses

PagedNormalStatementHandler

Instance Attribute Summary collapse

Attributes inherited from StatementHandler

#statement

Instance Method Summary collapse

Methods inherited from StatementHandler

build_statement_handler

Constructor Details

#initialize(plugin) ⇒ NormalStatementHandler

Returns a new instance of NormalStatementHandler.



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/logstash/plugin_mixins/jdbc/statement_handler.rb', line 38

def initialize(plugin)
  super(plugin)
  @parameter_keys = ["sql_last_value"] + plugin.parameters.keys
  @parameters = plugin.parameters.inject({}) do |hash,(k,v)|
    case v
    when LogStash::Timestamp
      hash[k.to_sym] = v.time
    else
      hash[k.to_sym] = v
    end
    hash
  end
end

Instance Attribute Details

#parametersObject (readonly)

Returns the value of attribute parameters.



36
37
38
# File 'lib/logstash/plugin_mixins/jdbc/statement_handler.rb', line 36

def parameters
  @parameters
end

Instance Method Details

#perform_query(db, sql_last_value) {|row| ... } ⇒ Object

Performs the query, yielding once per row of data

Parameters:

  • db (Sequel::Database)
  • sql_last_value (Integer|DateTime|Time)

Yield Parameters:

  • row (Hash{Symbol=>Object})


56
57
58
59
60
61
# File 'lib/logstash/plugin_mixins/jdbc/statement_handler.rb', line 56

def perform_query(db, sql_last_value)
  query = build_query(db, sql_last_value)
  query.each do |row|
    yield row
  end
end