Sha256: 1a45c64cafaef6df7f2b8b24a4a57a6d9f5968722db621b86a4e8673b5ef27fb

Contents?: true

Size: 1.03 KB

Versions: 45

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Karafka
  module Connection
    # Abstraction layer around listeners batch.
    class ListenersBatch
      include Enumerable

      attr_reader :coordinators

      # @param jobs_queue [JobsQueue]
      # @return [ListenersBatch]
      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

      # Iterates over available listeners and yields each listener
      # @param block [Proc] block we want to run
      def each(&block)
        @batch.each(&block)
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
karafka-2.2.12 lib/karafka/connection/listeners_batch.rb
karafka-2.2.11 lib/karafka/connection/listeners_batch.rb
karafka-2.2.10 lib/karafka/connection/listeners_batch.rb
karafka-2.2.9 lib/karafka/connection/listeners_batch.rb
karafka-2.2.8 lib/karafka/connection/listeners_batch.rb
karafka-2.2.8.beta1 lib/karafka/connection/listeners_batch.rb
karafka-2.2.7 lib/karafka/connection/listeners_batch.rb
karafka-2.2.6 lib/karafka/connection/listeners_batch.rb
karafka-2.2.5 lib/karafka/connection/listeners_batch.rb
karafka-2.2.4 lib/karafka/connection/listeners_batch.rb
karafka-2.2.3 lib/karafka/connection/listeners_batch.rb
karafka-2.2.2 lib/karafka/connection/listeners_batch.rb
karafka-2.2.1 lib/karafka/connection/listeners_batch.rb
karafka-2.2.0 lib/karafka/connection/listeners_batch.rb
karafka-2.1.13 lib/karafka/connection/listeners_batch.rb
karafka-2.1.12 lib/karafka/connection/listeners_batch.rb
karafka-2.1.11 lib/karafka/connection/listeners_batch.rb
karafka-2.1.10 lib/karafka/connection/listeners_batch.rb
karafka-2.1.9 lib/karafka/connection/listeners_batch.rb
karafka-2.1.8 lib/karafka/connection/listeners_batch.rb