Class: LogStash::OutputDelegatorStrategies::Legacy

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, metric, execution_context, plugin_args) ⇒ Legacy

Returns a new instance of Legacy.



5
6
7
8
9
10
11
12
13
14
# File 'lib/logstash/output_delegator_strategies/legacy.rb', line 5

def initialize(klass, metric, execution_context, plugin_args)
  @worker_count = (plugin_args["workers"] || 1).to_i
  @workers = @worker_count.times.map { klass.new(plugin_args) }
  @workers.each do |w|
    w.metric = metric
    w.execution_context = execution_context
  end
  @worker_queue = SizedQueue.new(@worker_count)
  @workers.each {|w| @worker_queue << w}
end

Instance Attribute Details

#worker_countObject (readonly)

Returns the value of attribute worker_count.



3
4
5
# File 'lib/logstash/output_delegator_strategies/legacy.rb', line 3

def worker_count
  @worker_count
end

#workersObject (readonly)

Returns the value of attribute workers.



3
4
5
# File 'lib/logstash/output_delegator_strategies/legacy.rb', line 3

def workers
  @workers
end

Instance Method Details

#do_closeObject



27
28
29
30
# File 'lib/logstash/output_delegator_strategies/legacy.rb', line 27

def do_close
  # No mutex needed since this is only called when the pipeline is clear
  @workers.each(&:do_close)
end

#multi_receive(events) ⇒ Object



20
21
22
23
24
25
# File 'lib/logstash/output_delegator_strategies/legacy.rb', line 20

def multi_receive(events)
  worker = @worker_queue.pop
  worker.multi_receive(events)
ensure
  @worker_queue << worker if worker
end

#registerObject



16
17
18
# File 'lib/logstash/output_delegator_strategies/legacy.rb', line 16

def register
  @workers.each(&:register)
end