Class: LogStash::Inputs::BeatsSupport::SynchronousQueueWithOffer
- Inherits:
-
Object
- Object
- LogStash::Inputs::BeatsSupport::SynchronousQueueWithOffer
- Defined in:
- lib/logstash/inputs/beats_support/synchronous_queue_with_offer.rb
Instance Method Summary collapse
-
#initialize(timeout, fairness_policy = true) ⇒ SynchronousQueueWithOffer
constructor
A new instance of SynchronousQueueWithOffer.
-
#offer(element, timeout = nil) ⇒ Object
This method will return true if it successfully added the element to the queue.
- #take ⇒ Object
Constructor Details
#initialize(timeout, fairness_policy = true) ⇒ SynchronousQueueWithOffer
Returns a new instance of SynchronousQueueWithOffer.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/logstash/inputs/beats_support/synchronous_queue_with_offer.rb', line 13 def initialize(timeout, fairness_policy = true) # set Fairness policy to `FIFO` # # In the context of the input it makes sense to # try to deal with the older connection before # the newer one, since the older will be closer to # reach the connection timeout. # @timeout = timeout @queue = java.util.concurrent.SynchronousQueue.new(fairness_policy) end |
Instance Method Details
#offer(element, timeout = nil) ⇒ Object
This method will return true if it successfully added the element to the queue. If the timeout is reached and it wasn’t inserted successfully to the queue it will return false.
28 29 30 |
# File 'lib/logstash/inputs/beats_support/synchronous_queue_with_offer.rb', line 28 def offer(element, timeout = nil) @queue.offer(element, timeout || @timeout, java.util.concurrent.TimeUnit::SECONDS) end |
#take ⇒ Object
32 33 34 |
# File 'lib/logstash/inputs/beats_support/synchronous_queue_with_offer.rb', line 32 def take @queue.take end |