class LogStash::Inputs::Example
Generate a repeating message.
This plugin is intented only as an example.
Public Instance Methods
register()
click to toggle source
# File lib/logstash/inputs/example.rb, line 26 def register @host = Socket.gethostname end
run(queue)
click to toggle source
# File lib/logstash/inputs/example.rb, line 30 def run(queue) # we can abort the loop if stop? becomes true while !stop? event = LogStash::Event.new("message" => @message, "host" => @host) decorate(event) queue << event # because the sleep interval can be big, when shutdown happens # we want to be able to abort the sleep # Stud.stoppable_sleep will frequently evaluate the given block # and abort the sleep(@interval) if the return value is true Stud.stoppable_sleep(@interval) { stop? } end # loop end
stop()
click to toggle source
# File lib/logstash/inputs/example.rb, line 44 def stop # nothing to do in this case so it is not necessary to define stop # examples of common "stop" tasks: # * close sockets (unblocking blocking reads/accepts) # * cleanup temporary files # * terminate spawned threads end