Class: LogStash::PluginMixins::Jdbc::PreparedStatementHandler

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

Instance Attribute Summary collapse

Attributes inherited from StatementHandler

#statement

Instance Method Summary collapse

Methods inherited from StatementHandler

build_statement_handler

Constructor Details

#initialize(plugin) ⇒ PreparedStatementHandler

Returns a new instance of PreparedStatementHandler.



129
130
131
132
133
134
135
# File 'lib/logstash/plugin_mixins/jdbc/statement_handler.rb', line 129

def initialize(plugin)
  super(plugin)
  @name = plugin.prepared_statement_name.to_sym
  @bind_values_array = plugin.prepared_statement_bind_values
  @parameters = plugin.parameters
  @statement_prepared = Concurrent::AtomicBoolean.new(false)
end

Instance Attribute Details

#bind_values_arrayObject (readonly)

Returns the value of attribute bind_values_array.



127
128
129
# File 'lib/logstash/plugin_mixins/jdbc/statement_handler.rb', line 127

def bind_values_array
  @bind_values_array
end

#nameObject (readonly)

Returns the value of attribute name.



127
128
129
# File 'lib/logstash/plugin_mixins/jdbc/statement_handler.rb', line 127

def name
  @name
end

#parametersObject (readonly)

Returns the value of attribute parameters.



127
128
129
# File 'lib/logstash/plugin_mixins/jdbc/statement_handler.rb', line 127

def parameters
  @parameters
end

#preparedObject (readonly)

Returns the value of attribute prepared.



127
128
129
# File 'lib/logstash/plugin_mixins/jdbc/statement_handler.rb', line 127

def prepared
  @prepared
end

#statement_preparedObject (readonly)

Returns the value of attribute statement_prepared.



127
128
129
# File 'lib/logstash/plugin_mixins/jdbc/statement_handler.rb', line 127

def statement_prepared
  @statement_prepared
end

Instance Method Details

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

Performs the query, ignoring our pagination settings, yielding once per row of data

Parameters:

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

Yield Parameters:

  • row (Hash{Symbol=>Object})


141
142
143
144
145
146
# File 'lib/logstash/plugin_mixins/jdbc/statement_handler.rb', line 141

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