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:



11
12
13
# File 'lib/karafka/processing/workers_batch.rb', line 11

def initialize(jobs_queue)
  @batch = Array.new(App.config.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



17
18
19
# File 'lib/karafka/processing/workers_batch.rb', line 17

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

#sizeInteger

Returns number of workers in the batch.

Returns:

  • (Integer)

    number of workers in the batch



22
23
24
# File 'lib/karafka/processing/workers_batch.rb', line 22

def size
  @batch.size
end