Module: Karafka::Pro::Routing::Features::Patterns::Topic
- Defined in:
- lib/karafka/pro/routing/features/patterns/topic.rb
Overview
Patterns feature topic extensions
Instance Method Summary collapse
-
#initialize ⇒ Object
This method calls the parent class initializer and then sets up the extra instance variable to nil.
-
#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 calls the parent class initializer and then sets up the extra instance variable to nil. The explicit initialization to nil is included as an optimization for Ruby’s object shapes system, which improves memory layout and access performance.
17 18 19 20 |
# File 'lib/karafka/pro/routing/features/patterns/topic.rb', line 17 def initialize(...) super @patterns = nil end |
#patterns(active: false, type: :regular, pattern: nil) ⇒ Object
31 32 33 |
# File 'lib/karafka/pro/routing/features/patterns/topic.rb', line 31 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.
36 37 38 |
# File 'lib/karafka/pro/routing/features/patterns/topic.rb', line 36 def patterns? patterns.active? end |
#subscription_name ⇒ String
Returns subscription name or the regexp string representing matching of new topics that should be detected.
24 25 26 |
# File 'lib/karafka/pro/routing/features/patterns/topic.rb', line 24 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.
41 42 43 44 45 |
# File 'lib/karafka/pro/routing/features/patterns/topic.rb', line 41 def to_h super.merge( patterns: patterns.to_h ).freeze end |