Class: Karafka::Processing::WorkersBatch

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/karafka/processing/workers_batch.rb

Overview

Abstraction layer around workers batch.

Instance Method Summary collapse

Constructor Details

#initialize(jobs_queue) ⇒ WorkersBatch

Parameters:



14
15
16
# File 'lib/karafka/processing/workers_batch.rb', line 14

def initialize(jobs_queue)
  @batch = Array.new(concurrency) { Processing::Worker.new(jobs_queue) }
end

Instance Method Details

#each(&block) ⇒ Object

Iterates over available workers and yields each worker

Parameters:

  • block (Proc)

    block we want to run



20
21
22
# File 'lib/karafka/processing/workers_batch.rb', line 20

def each(&block)
  @batch.each(&block)
end

#sizeInteger

Returns number of workers in the batch.

Returns:

  • (Integer)

    number of workers in the batch



25
26
27
# File 'lib/karafka/processing/workers_batch.rb', line 25

def size
  @batch.size
end