Class: LogStash::Filters::FetchStrategy::File::RegexUnion

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/filters/fetch_strategy/file.rb

Instance Method Summary collapse

Constructor Details

#initialize(dictionary, rw_lock) ⇒ RegexUnion

Returns a new instance of RegexUnion.



58
59
60
61
# File 'lib/logstash/filters/fetch_strategy/file.rb', line 58

def initialize(dictionary, rw_lock)
  @dictionary = dictionary
  @read_lock = rw_lock.readLock
end

Instance Method Details

#dictionary_updatedObject



63
64
65
# File 'lib/logstash/filters/fetch_strategy/file.rb', line 63

def dictionary_updated
  @union_regex_keys = Regexp.union(@dictionary.keys)
end

#fetch(source, results) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/logstash/filters/fetch_strategy/file.rb', line 67

def fetch(source, results)
  @read_lock.lock
  begin
    value = source.gsub(@union_regex_keys, @dictionary)
    if source == value
      results[0] = false
    else
      results[1] = LogStash::Util.deep_clone(value)
    end
  ensure
    @read_lock.unlock
  end
end