Class: Karafka::Web::Pro::Commanding::Matchers::PartitionId
- Defined in:
- lib/karafka/web/pro/commanding/matchers/partition_id.rb
Overview
Note:
This matcher only checks for partition_id presence across all topics. For topic-specific partition matching, use this in combination with the Topic matcher.
Matcher that checks if the current process has a specific partition assigned. Uses the Karafka assignments tracker to check actual current assignments. This is an optional matcher that only applies when partition_id is specified.
Instance Method Summary collapse
-
#apply? ⇒ Boolean
True if partition_id criterion is specified in matchers.
-
#matches? ⇒ Boolean
Checks if this process has the specified partition assigned (any topic).
Methods inherited from Base
Constructor Details
This class inherits a constructor from Karafka::Web::Pro::Commanding::Matchers::Base
Instance Method Details
#apply? ⇒ Boolean
Returns true if partition_id criterion is specified in matchers.
45 46 47 |
# File 'lib/karafka/web/pro/commanding/matchers/partition_id.rb', line 45 def apply? !partition_id.nil? end |
#matches? ⇒ Boolean
Checks if this process has the specified partition assigned (any topic)
52 53 54 55 56 |
# File 'lib/karafka/web/pro/commanding/matchers/partition_id.rb', line 52 def matches? ::Karafka::App.assignments.any? do |_topic, partitions| partitions.include?(partition_id) end end |