Class: Karafka::Web::Pro::Commanding::Matchers::Topic

Inherits:
Base
  • Object
show all
Defined in:
lib/karafka/web/pro/commanding/matchers/topic.rb

Overview

Matcher that checks if the current process has any assignments for the topic specified in the message matchers. Uses the Karafka assignments tracker to check actual current assignments rather than just routing configuration. This is an optional matcher that only applies when topic is specified.

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Karafka::Web::Pro::Commanding::Matchers::Base

Instance Method Details

#apply?Boolean

Returns true if topic criterion is specified in matchers.

Returns:

  • (Boolean)

    true if topic criterion is specified in matchers



42
43
44
# File 'lib/karafka/web/pro/commanding/matchers/topic.rb', line 42

def apply?
  !topic_name.nil?
end

#matches?Boolean

Checks if this process has any partitions assigned for the specified topic

Returns:

  • (Boolean)

    true if this process has partitions assigned for the topic



49
50
51
52
53
# File 'lib/karafka/web/pro/commanding/matchers/topic.rb', line 49

def matches?
  ::Karafka::App.assignments.any? do |topic, _partitions|
    topic.name == topic_name
  end
end