Class: LogStash::Outputs::TestSink::Queue

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/test_sink.rb

Overview

TODO refactor to java.util.concurrent.ConcurrentLinkedQueue Interestingly, using a ConcurrentLinkedQueue gets specs that depend on pop-ing events from the output (e.g. syslog input plugin) passing fine with the old Ruby pipeline. The Java pipeline seems to reach a shutdown before the input yielded events are to be consumed.

Instance Method Summary collapse

Constructor Details

#initialize(poll_timeout = nil) ⇒ Queue

Returns a new instance of Queue.



86
87
88
89
# File 'lib/logstash/outputs/test_sink.rb', line 86

def initialize(poll_timeout = nil)
  super()
  @timeout = poll_timeout.to_i
end

Instance Method Details

#pop(non_block = nil) ⇒ Object Also known as: deq, shift

Ruby Queue like pop-er with (default) blocking.

See Also:



93
94
95
96
97
98
# File 'lib/logstash/outputs/test_sink.rb', line 93

def pop(non_block = nil)
  # for compatibility we're making it behave like Ruby's Queue
  return poll if non_block
  @timeout.zero? ? take :
      (poll(@timeout, MILLISECONDS) || timeout!(__method__))
end