lib/logstash/codecs/identity_map_codec.rb in logstash-codec-multiline-2.0.3 vs lib/logstash/codecs/identity_map_codec.rb in logstash-codec-multiline-2.0.4

- old
+ new

@@ -99,11 +99,12 @@ @base_codecs = [codec] @identity_map = ThreadSafe::Hash.new &method(:codec_builder) @max_identities = MAX_IDENTITIES @evict_timeout = EVICT_TIMEOUT @cleaner = MapCleaner.new(self, CLEANER_INTERVAL) - @decode_block = lambda {|*| } + @decode_block = lambda {|*| true } + @eviction_block = nil end # ============================================== # Constructional/builder methods # chain this method off of new @@ -124,10 +125,16 @@ def cleaner_interval(interval) @cleaner.stop @cleaner = MapCleaner.new(self, interval.to_i) self end + + # used to add a non-default eviction block + def eviction_block(block) + @eviction_block = block + self + end # end Constructional/builder methods # ============================================== # ============================================== # Codec API @@ -182,10 +189,10 @@ cut_off = Time.now.to_i # delete_if is atomic # contents should not mutate during this call identity_map.delete_if do |identity, compo| if (flag = compo.timeout <= cut_off) - compo.codec.flush(&@decode_block) + compo.codec.flush(&(@eviction_block || @decode_block)) end flag end current_size_and_limit end