Class: LogStash::MultiQueue
- Inherits:
-
Object
- Object
- LogStash::MultiQueue
- Defined in:
- lib/logstash/multiqueue.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
- #add_queue(queue) ⇒ Object
-
#initialize(*queues) ⇒ MultiQueue
constructor
A new instance of MultiQueue.
- #push(object) ⇒ Object (also: #<<)
- #remove_queue(queue) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(*queues) ⇒ MultiQueue
Returns a new instance of MultiQueue.
9 10 11 12 13 |
# File 'lib/logstash/multiqueue.rb', line 9 def initialize(*queues) @logger = Cabin::Channel.get(LogStash) @mutex = Mutex.new @queues = queues end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/logstash/multiqueue.rb', line 6 def logger @logger end |
Instance Method Details
#add_queue(queue) ⇒ Object
36 37 38 39 40 |
# File 'lib/logstash/multiqueue.rb', line 36 def add_queue(queue) @mutex.synchronize do @queues << queue end end |
#push(object) ⇒ Object Also known as: <<
27 28 29 |
# File 'lib/logstash/multiqueue.rb', line 27 def push(object) @queues.each { |q| q.push(object) } end |
#remove_queue(queue) ⇒ Object
43 44 45 46 47 |
# File 'lib/logstash/multiqueue.rb', line 43 def remove_queue(queue) @mutex.synchronize do @queues.delete(queue) end end |
#size ⇒ Object
50 51 52 |
# File 'lib/logstash/multiqueue.rb', line 50 def size return @queues.collect { |q| q.size } end |