Class: LogStash::OutputDelegatorStrategies::Legacy
- Inherits:
-
Object
- Object
- LogStash::OutputDelegatorStrategies::Legacy
- Defined in:
- lib/logstash/output_delegator_strategies/legacy.rb
Instance Attribute Summary collapse
-
#worker_count ⇒ Object
readonly
Returns the value of attribute worker_count.
-
#workers ⇒ Object
readonly
Returns the value of attribute workers.
Instance Method Summary collapse
- #do_close ⇒ Object
-
#initialize(logger, klass, metric, plugin_args) ⇒ Legacy
constructor
A new instance of Legacy.
- #multi_receive(events) ⇒ Object
- #register ⇒ Object
Constructor Details
#initialize(logger, klass, metric, plugin_args) ⇒ Legacy
Returns a new instance of Legacy.
5 6 7 8 9 10 11 |
# File 'lib/logstash/output_delegator_strategies/legacy.rb', line 5 def initialize(logger, klass, metric, plugin_args) @worker_count = (plugin_args["workers"] || 1).to_i @workers = @worker_count.times.map { klass.new(plugin_args) } @workers.each {|w| w.metric = metric } @worker_queue = SizedQueue.new(@worker_count) @workers.each {|w| @worker_queue << w} end |
Instance Attribute Details
#worker_count ⇒ Object (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 |
#workers ⇒ Object (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_close ⇒ Object
24 25 26 27 |
# File 'lib/logstash/output_delegator_strategies/legacy.rb', line 24 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
17 18 19 20 21 22 |
# File 'lib/logstash/output_delegator_strategies/legacy.rb', line 17 def multi_receive(events) worker = @worker_queue.pop worker.multi_receive(events) ensure @worker_queue << worker if worker end |
#register ⇒ Object
13 14 15 |
# File 'lib/logstash/output_delegator_strategies/legacy.rb', line 13 def register @workers.each(&:register) end |