Sha256: ce04d6a0d9e26baad7e577ca1289bd7f0e43afb8be4c6d8692aaef0c417dcf71
Contents?: true
Size: 1.26 KB
Versions: 32
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module Karafka module Routing module Features class DeadLetterQueue < Base # Rules around dead letter queue settings class Contract < Contracts::Base configure do |config| config.error_messages = YAML.safe_load( File.read( File.join(Karafka.gem_root, 'config', 'locales', 'errors.yml') ) ).fetch('en').fetch('validations').fetch('topic') end nested :dead_letter_queue do required(:active) { |val| [true, false].include?(val) } required(:max_retries) { |val| val.is_a?(Integer) && val >= 0 } end # Validate topic name only if dlq is active virtual do |data, errors| next unless errors.empty? dead_letter_queue = data[:dead_letter_queue] next unless dead_letter_queue[:active] topic = dead_letter_queue[:topic] # When topic is set to false, it means we just want to skip dispatch on DLQ next if topic == false next if topic.is_a?(String) && Contracts::TOPIC_REGEXP.match?(topic) [[%i[dead_letter_queue topic], :format]] end end end end end end
Version data entries
32 entries across 32 versions & 1 rubygems