Class: LogStash::MultiQueue

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#loggerObject

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

#sizeObject



50
51
52
# File 'lib/logstash/multiqueue.rb', line 50

def size
  return @queues.collect { |q| q.size }
end