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.



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

def initialize(handler)
  @file_handler = handler
  set_initial
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



32
33
34
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 32

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
26
27
28
29
30
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 7

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

  handler = NullFileHandler.new(plugin.)
  if plugin.record_last_run
    handler = FileHandler.new(plugin.)
  end
  if plugin.clean_run
    handler.clean
  end

  instance = klass.new(handler)
end

Instance Method Details

#set_initialObject



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

def set_initial
  # override in subclass
end

#set_value(value) ⇒ Object



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

def set_value(value)
  # override in subclass
end

#writeObject



47
48
49
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 47

def write
  @file_handler.write(@value)
end