Class: Karafka::Web::Pro::Commanding::Matcher
- Inherits:
-
Object
- Object
- Karafka::Web::Pro::Commanding::Matcher
- Defined in:
- lib/karafka/web/pro/commanding/matcher.rb
Overview
Matcher that makes a decision whether a given command message should be applied/executed within the context of the current consumer process.
Since we use the assign
, each process listens to this topic and receives messages with commands targeting all the processes, this is why it needs to be filtered.
Instance Method Summary collapse
-
#matches?(message) ⇒ Boolean
Is this message dedicated to current process and is actionable.
Instance Method Details
#matches?(message) ⇒ Boolean
Returns is this message dedicated to current process and is actionable.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/karafka/web/pro/commanding/matcher.rb', line 26 def matches?() matches = true # We want to work only with commands that target all processes or our current matches = false unless .key == '*' || .key == process_id # We operate only on commands. Result messages should be ignored matches = false unless .payload[:type] == 'command' # Ignore messages that have different schema. This can happen in the middle of # upgrades of the framework. We ignore this not to risk compatibility issues matches = false unless .payload[:schema_version] == Dispatcher::SCHEMA_VERSION matches end |