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

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

Constant Summary collapse

YAML_PERMITTED_CLASSES =
[::DateTime, ::Time, ::BigDecimal].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handler) ⇒ ValueTracking

Returns a new instance of ValueTracking.



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

def initialize(handler)
  @file_handler = handler
  set_initial
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



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

def value
  @value
end

Class Method Details

.build_last_value_tracker(plugin) ⇒ Object



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

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?
      # no TZ stuff for Sequel, use Time
      TimeValueTracker.new(handler)
    else
      # Sequel does timezone handling on DateTime only
      DateTimeValueTracker.new(handler)
    end
  end
end

.load_yaml(source) ⇒ Object



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

def self.load_yaml(source)
  Psych::safe_load(source, permitted_classes: YAML_PERMITTED_CLASSES)
end

Instance Method Details

#set_initialObject



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

def set_initial
  # override in subclass
end

#set_value(value) ⇒ Object



51
52
53
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 51

def set_value(value)
  # override in subclass
end

#writeObject



55
56
57
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 55

def write
  @file_handler.write(@value)
end