Class: Karafka::Pro::RecurringTasks::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/pro/recurring_tasks/matcher.rb

Overview

Matcher used to check if given command can be applied to a given task.

Instance Method Summary collapse

Instance Method Details

#matches?(task, payload) ⇒ Boolean

Returns is this message dedicated to current process and is actionable.

Parameters:

Returns:

  • (Boolean)

    is this message dedicated to current process and is actionable



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/karafka/pro/recurring_tasks/matcher.rb', line 22

def matches?(task, payload)
  # We only match commands
  return false unless payload[:type] == 'command'

  # * is a wildcard to match all for batch commands
  return false unless payload[:task][:id] == '*' || payload[:task][:id] == task.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] == Serializer::SCHEMA_VERSION

  true
end