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

Instance Method Details

#patterns(active: false, type: :regular, pattern: nil) ⇒ Object

Parameters:

  • active (Boolean) (defaults to: false)

    is this topic active member of patterns

  • type (Symbol) (defaults to: :regular)

    type of topic taking part in pattern matching

  • pattern (Regexp) (defaults to: nil)

    regular expression for matching



30
31
32
# File 'lib/karafka/pro/routing/features/patterns/topic.rb', line 30

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.

Returns:

  • (Boolean)

    is this topic a member of patterns



35
36
37
# File 'lib/karafka/pro/routing/features/patterns/topic.rb', line 35

def patterns?
  patterns.active?
end

#subscription_nameString

Returns subscription name or the regexp string representing matching of new topics that should be detected.

Returns:

  • (String)

    subscription name or the regexp string representing matching of new topics that should be detected.



23
24
25
# File 'lib/karafka/pro/routing/features/patterns/topic.rb', line 23

def subscription_name
  patterns.active? && patterns.matcher? ? patterns.pattern.regexp_string : super
end

#to_hHash

Returns topic with all its native configuration options plus patterns.

Returns:

  • (Hash)

    topic with all its native configuration options plus patterns



40
41
42
43
44
# File 'lib/karafka/pro/routing/features/patterns/topic.rb', line 40

def to_h
  super.merge(
    patterns: patterns.to_h
  ).freeze
end