Module: Karafka::Pro::Routing::Features::Patterns::Topics

Defined in:
lib/karafka/pro/routing/features/patterns/topics.rb

Overview

Patterns feature topic extensions

Instance Method Summary collapse

Instance Method Details

#find(topic_name) ⇒ Karafka::Routing::Topic

Note:

This method should not be used in context of finding multiple missing topics in loops because it catches exceptions and attempts to expand routes. If this is used in a loop for lookups on thousands of topics with detector expansion, this may be slow. It should be used in the context where newly discovered topics are found and should by design match a pattern. For quick lookups on batches of topics, it is recommended to use a custom built lookup with conditional expander.

Finds topic by its name in a more extensive way than the regular. Regular uses the pre-existing topics definitions. This extension also runs the expansion based on defined routing patterns (if any)

If topic does not exist, it will try to run discovery in case there are patterns defined that would match it. This allows us to support lookups for newly appearing topics based on their regexp patterns.

Parameters:

  • topic_name (String)

    topic name

Returns:

Raises:



41
42
43
44
45
46
47
# File 'lib/karafka/pro/routing/features/patterns/topics.rb', line 41

def find(topic_name)
  super
rescue Karafka::Errors::TopicNotFoundError
  Detector.new.expand(self, topic_name)

  super
end