Class: Karafka::Connection::ListenersBatch

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/karafka/connection/listeners_batch.rb

Overview

Abstraction layer around listeners batch.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(jobs_queue) ⇒ ListenersBatch

Parameters:

  • jobs_queue (JobsQueue)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/karafka/connection/listeners_batch.rb', line 13

def initialize(jobs_queue)
  @coordinators = []

  @batch = App.subscription_groups.flat_map do |_consumer_group, subscription_groups|
    consumer_group_coordinator = Connection::ConsumerGroupCoordinator.new(
      subscription_groups.size
    )

    @coordinators << consumer_group_coordinator

    subscription_groups.map do |subscription_group|
      Connection::Listener.new(
        consumer_group_coordinator,
        subscription_group,
        jobs_queue
      )
    end
  end
end

Instance Attribute Details

#coordinatorsObject (readonly)

Returns the value of attribute coordinators.



9
10
11
# File 'lib/karafka/connection/listeners_batch.rb', line 9

def coordinators
  @coordinators
end

Instance Method Details

#each(&block) ⇒ Object

Iterates over available listeners and yields each listener

Parameters:

  • block (Proc)

    block we want to run



35
36
37
# File 'lib/karafka/connection/listeners_batch.rb', line 35

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