Class: Karafka::Web::Pro::Ui::Lib::PatternsDetector
- Inherits:
-
Object
- Object
- Karafka::Web::Pro::Ui::Lib::PatternsDetector
- Defined in:
- lib/karafka/web/pro/ui/lib/patterns_detector.rb
Overview
Checks list of topics and tries to match them against the available patterns Uses the Pro detector to expand routes in the Web-UI so we include topics that are or will be matched using our regular expressions
This code needs to run when using deserializers of messages from patterns. Otherwise default deserializer will be used instead.
Instance Method Summary collapse
-
#call ⇒ Object
Run the detection.
Instance Method Details
#call ⇒ Object
Run the detection
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/karafka/web/pro/ui/lib/patterns_detector.rb', line 20 def call detector = ::Karafka::Pro::Routing::Features::Patterns::Detector.new topics_names = Web::Ui::Models::ClusterInfo.topics.map(&:topic_name) Karafka::App .routes .flat_map(&:subscription_groups) .each do |subscription_group| sg_topics = subscription_group.topics # Reject topics that are already part of routing for given subscription groups # and then for remaining try to apply patterns and expand routes topics_names .reject { |t_name| sg_topics.any? { |rtopic| rtopic.name == t_name } } .each { |t_name| detector.(sg_topics, t_name) } end end |