Sha256: 78ffb2712753925d792373b3d09d4f009247e9888d8cc583bff8b896275dd360

Contents?: true

Size: 1.46 KB

Versions: 6

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

# This Karafka component is a Pro component under a commercial license.
# This Karafka component is NOT licensed under LGPL.
#
# All of the commercial components are present in the lib/karafka/pro directory of this
# repository and their usage requires commercial license agreement.
#
# Karafka has also commercial-friendly license, commercial support and commercial components.
#
# By sending a pull request to the pro components, you are agreeing to transfer the copyright of
# your code to Maciej Mensfeld.

module Karafka
  module Pro
    module RecurringTasks
      # Matcher used to check if given command can be applied to a given task.
      class Matcher
        # @param task [Karafka::Pro::RecurringTasks::Task]
        # @param payload [Hash] command message payload
        # @return [Boolean] is this message dedicated to current process and is actionable
        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
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
karafka-2.4.14 lib/karafka/pro/recurring_tasks/matcher.rb
karafka-2.4.13 lib/karafka/pro/recurring_tasks/matcher.rb
karafka-2.4.12 lib/karafka/pro/recurring_tasks/matcher.rb
karafka-2.4.11 lib/karafka/pro/recurring_tasks/matcher.rb
karafka-2.4.10 lib/karafka/pro/recurring_tasks/matcher.rb
karafka-2.4.9 lib/karafka/pro/recurring_tasks/matcher.rb