Class: LogStash::PluginMixins::JdbcStreaming::StatementHandler

Inherits:
Object
  • Object
show all
Includes:
LogStash::PluginMixins::Jdbc::ValueHandler
Defined in:
lib/logstash/plugin_mixins/jdbc_streaming/statement_handler.rb

Overview

so as to not clash with the class of the same name and function in the jdbc input this is in the module JdbcStreaming namespace this duplication can be removed in a universal plugin

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LogStash::PluginMixins::Jdbc::ValueHandler

#decorate_value, #extract_values_from

Constructor Details

#initialize(plugin) ⇒ StatementHandler

Returns a new instance of StatementHandler.



20
21
22
23
24
25
# File 'lib/logstash/plugin_mixins/jdbc_streaming/statement_handler.rb', line 20

def initialize(plugin)
  @statement = plugin.statement
  klass = plugin.use_cache ? RowCache : NoCache
  @cache = klass.new(plugin.cache_size, plugin.cache_expiration)
  post_init(plugin)
end

Instance Attribute Details

#cacheObject (readonly)

Returns the value of attribute cache.



18
19
20
# File 'lib/logstash/plugin_mixins/jdbc_streaming/statement_handler.rb', line 18

def cache
  @cache
end

#parametersObject (readonly)

Returns the value of attribute parameters.



18
19
20
# File 'lib/logstash/plugin_mixins/jdbc_streaming/statement_handler.rb', line 18

def parameters
  @parameters
end

#statementObject (readonly)

Returns the value of attribute statement.



18
19
20
# File 'lib/logstash/plugin_mixins/jdbc_streaming/statement_handler.rb', line 18

def statement
  @statement
end

Class Method Details

.build_statement_handler(plugin) ⇒ Object



13
14
15
16
# File 'lib/logstash/plugin_mixins/jdbc_streaming/statement_handler.rb', line 13

def self.build_statement_handler(plugin)
  klass = plugin.use_prepared_statements ? PreparedStatementHandler : NormalStatementHandler
  klass.new(plugin)
end

Instance Method Details

#cache_lookup(db, event) ⇒ Object

Get from cache or performs remote lookup and saves to cache

Parameters:

  • db (Sequel::Database)
  • event (LogStash::Event)


31
32
33
# File 'lib/logstash/plugin_mixins/jdbc_streaming/statement_handler.rb', line 31

def cache_lookup(db, event)
  # override in subclass
end