Module: Karafka::Pro::Routing::Features::DirectAssignments::SubscriptionGroup
- Defined in:
- lib/karafka/pro/routing/features/direct_assignments/subscription_group.rb
Overview
Extension allowing us to select correct subscriptions and assignments based on the expanded routing setup
Instance Method Summary collapse
-
#assignments(consumer) ⇒ Rdkafka::Consumer::TopicPartitionList
Final tpl for assignments.
-
#subscriptions ⇒ false, Array<String>
False if we do not have any subscriptions or array with all the subscriptions for given subscription group.
Instance Method Details
#assignments(consumer) ⇒ Rdkafka::Consumer::TopicPartitionList
Returns final tpl for assignments.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/karafka/pro/routing/features/direct_assignments/subscription_group.rb', line 37 def assignments(consumer) topics .select(&:active?) .select { |topic| topic.direct_assignments.active? } .map { |topic| build_assignments(topic) } .to_h .tap { |topics| return false if topics.empty? } .then { |topics| Iterator::Expander.new.call(topics) } .then { |topics| Iterator::TplBuilder.new(consumer, topics).call } end |
#subscriptions ⇒ false, Array<String>
Returns false if we do not have any subscriptions or array with all the subscriptions for given subscription group.
26 27 28 29 30 31 32 |
# File 'lib/karafka/pro/routing/features/direct_assignments/subscription_group.rb', line 26 def subscriptions topics .select(&:active?) .reject { |topic| topic.direct_assignments.active? } .map(&:subscription_name) .then { |subscriptions| subscriptions.empty? ? false : subscriptions } end |