lib/logstash/inputs/heartbeat.rb in logstash-input-heartbeat-1.0.0 vs lib/logstash/inputs/heartbeat.rb in logstash-input-heartbeat-2.0.0
- old
+ new
@@ -43,17 +43,18 @@
@host = Socket.gethostname
end # def register
def run(queue)
sequence = 0
+ @thread = Thread.current
Stud.interval(@interval) do
sequence += 1
event = generate_message(sequence)
decorate(event)
queue << event
- break if sequence == @count
+ break if sequence == @count || stop?
end # loop
end # def run
public
@@ -65,6 +66,9 @@
else
LogStash::Event.new("message" => @message, "host" => @host)
end
end
+ def stop
+ Stud.stop!(@thread)
+ end
end # class LogStash::Inputs::Heartbeat