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.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/karafka/web/pro/commanding/matcher.rb', line 18 def matches?() # We operate only on commands. Result and other messages should be ignored return false unless .headers['type'] == 'request' # We want to work only with commands that target all processes or our current return false unless .key == '*' || .key == process_id # 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 return false unless .payload[:schema_version] == Dispatcher::SCHEMA_VERSION true end |