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
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/karafka/web/pro/ui/lib/patterns_detector.rb', line 45 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 |