Module: Karafka::Pro::Routing::Features::Multiplexing::SubscriptionGroupsBuilder

Defined in:
lib/karafka/pro/routing/features/multiplexing/subscription_groups_builder.rb

Overview

Expands the builder to multiply multiplexed groups

Instance Method Summary collapse

Instance Method Details

#expand(topics_array) ⇒ Array<Array<Routing::Topics>>

Takes into consideration multiplexing and builds the more groups

Parameters:

  • topics_array (Array<Routing::Topic>)

    group of topics that have the same settings and can use the same connection

Returns:



26
27
28
29
30
31
32
33
34
# File 'lib/karafka/pro/routing/features/multiplexing/subscription_groups_builder.rb', line 26

def expand(topics_array)
  factor = topics_array.first.subscription_group_details.fetch(:multiplexing_max, 1)

  Array.new(factor) do |i|
    ::Karafka::Routing::Topics.new(
      i.zero? ? topics_array : topics_array.map(&:dup)
    )
  end
end