Module: Karafka::Pro::Routing::Features::ConsumerGroups::Patterns::Topic
- Defined in:
- lib/karafka/pro/routing/features/consumer_groups/patterns/topic.rb
Overview
Patterns feature topic extensions
Instance Method Summary collapse
-
#initialize ⇒ Object
This method sets up the extra instance variable to nil before calling the parent class initializer.
- #patterns(active: false, type: :regular, pattern: nil) ⇒ Object
-
#patterns? ⇒ Boolean
Is this topic a member of patterns.
-
#subscription_name ⇒ String
Subscription name or the regexp string representing matching of new topics that should be detected.
-
#to_h ⇒ Hash
Topic with all its native configuration options plus patterns.
Instance Method Details
#initialize ⇒ Object
This method sets up the extra instance variable to nil before calling the parent class initializer. The explicit initialization to nil is included as an optimization for Ruby’s object shapes system, which improves memory layout and access performance.
43 44 45 46 |
# File 'lib/karafka/pro/routing/features/consumer_groups/patterns/topic.rb', line 43 def initialize(...) @patterns = nil super end |
#patterns(active: false, type: :regular, pattern: nil) ⇒ Object
57 58 59 |
# File 'lib/karafka/pro/routing/features/consumer_groups/patterns/topic.rb', line 57 def patterns(active: false, type: :regular, pattern: nil) @patterns ||= Config.new(active: active, type: type, pattern: pattern) end |
#patterns? ⇒ Boolean
Returns is this topic a member of patterns.
62 63 64 |
# File 'lib/karafka/pro/routing/features/consumer_groups/patterns/topic.rb', line 62 def patterns? patterns.active? end |
#subscription_name ⇒ String
Returns subscription name or the regexp string representing matching of new topics that should be detected.
50 51 52 |
# File 'lib/karafka/pro/routing/features/consumer_groups/patterns/topic.rb', line 50 def subscription_name (patterns.active? && patterns.matcher?) ? patterns.pattern.regexp_string : super end |
#to_h ⇒ Hash
Returns topic with all its native configuration options plus patterns.
67 68 69 70 71 |
# File 'lib/karafka/pro/routing/features/consumer_groups/patterns/topic.rb', line 67 def to_h super.merge( patterns: patterns.to_h ).freeze end |