Class: Karafka::Pro::Routing::Features::Patterns::Patterns

Inherits:
Routing::Topics
  • Object
show all
Defined in:
lib/karafka/pro/routing/features/patterns/patterns.rb

Overview

Representation of groups of topics

Instance Method Summary collapse

Methods inherited from Routing::Topics

#delete_if, #each, #initialize

Constructor Details

This class inherits a constructor from Karafka::Routing::Topics

Instance Method Details

#find(topic_name) ⇒ Karafka::Routing::Pattern?

Note:

Please keep in mind, that there may be many patterns matching given topic name and we always pick the first one (defined first)

Finds first pattern matching given topic name

Parameters:

  • topic_name (String)

    topic name that may match a pattern

Returns:

  • (Karafka::Routing::Pattern, nil)

    pattern or nil if not found



27
28
29
# File 'lib/karafka/pro/routing/features/patterns/patterns.rb', line 27

def find(topic_name)
  @accumulator.find { |pattern| pattern.regexp =~ topic_name }
end