Class: LogStash::PluginMixins::Jdbc::ValueTracking

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handler) ⇒ ValueTracking

Returns a new instance of ValueTracking.



29
30
31
32
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 29

def initialize(handler)
  @file_handler = handler
  set_initial
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



27
28
29
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 27

def value
  @value
end

Class Method Details

.build_last_value_tracker(plugin) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 7

def self.build_last_value_tracker(plugin)
  handler = plugin.record_last_run ? FileHandler.new(plugin.) : NullFileHandler.new(plugin.)
  if plugin.clean_run
    handler.clean
  end

  if plugin.use_column_value && plugin.tracking_column_type == "numeric"
    # use this irrespective of the jdbc_default_timezone setting
    NumericValueTracker.new(handler)
  else
    if plugin.jdbc_default_timezone.nil? || plugin.jdbc_default_timezone.empty?
      # no TZ stuff for Sequel, use Time
      TimeValueTracker.new(handler)
    else
      # Sequel does timezone handling on DateTime only
      DateTimeValueTracker.new(handler)
    end
  end
end

Instance Method Details

#set_initialObject



34
35
36
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 34

def set_initial
  # override in subclass
end

#set_value(value) ⇒ Object



38
39
40
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 38

def set_value(value)
  # override in subclass
end

#writeObject



42
43
44
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 42

def write
  @file_handler.write(@value)
end