Class: LogStash::Codecs::IdentityMapCodec::MapCleaner

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/codecs/identity_map_codec.rb

Instance Method Summary collapse

Constructor Details

#initialize(imc, interval) ⇒ MapCleaner

Returns a new instance of MapCleaner.



41
42
43
44
# File 'lib/logstash/codecs/identity_map_codec.rb', line 41

def initialize(imc, interval)
  @imc, @interval = imc, interval
  @running = false
end

Instance Method Details

#running?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/logstash/codecs/identity_map_codec.rb', line 59

def running?
  @running
end

#startObject



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/logstash/codecs/identity_map_codec.rb', line 46

def start
  return self if running?
  @running = true
  @thread = Thread.new(@imc) do |imc|
    loop do
      sleep @interval
      break if !@running
      imc.map_cleanup
    end
  end
  self
end

#stopObject



63
64
65
66
67
# File 'lib/logstash/codecs/identity_map_codec.rb', line 63

def stop
  return if !running?
  @running = false
  @thread.wakeup if @thread.alive?
end