Sha256: ea0302552fd83297dd2f8cc45f2df92257d76d1c0b836b9f1de8966c2606fcb8

Contents?: true

Size: 1.27 KB

Versions: 23

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

module Karafka
  module Schemas
    # Validator to check responder topic usage
    ResponderUsageTopic = Dry::Validation.Schema do
      required(:name).filled(:str?, format?: Karafka::Schemas::TOPIC_REGEXP)
      required(:required).filled(:bool?)
      required(:multiple_usage).filled(:bool?)
      required(:usage_count).filled(:int?, gteq?: 0)
      required(:registered).filled(eql?: true)
      required(:async).filled(:bool?)

      rule(
        required_usage: %i[required usage_count]
      ) do |required, usage_count|
        required.true? > usage_count.gteq?(1)
      end

      rule(
        multiple_usage_permission: %i[multiple_usage usage_count]
      ) do |multiple_usage, usage_count|
        usage_count.gt?(1) > multiple_usage.true?
      end

      rule(
        multiple_usage_block: %i[multiple_usage usage_count]
      ) do |multiple_usage, usage_count|
        multiple_usage.false? > usage_count.lteq?(1)
      end
    end

    # Validator to check that everything in a responder flow matches responder rules
    ResponderUsage = Dry::Validation.Schema do
      required(:used_topics) { filled? > each { schema(ResponderUsageTopic) } }
      required(:registered_topics) { filled? > each { schema(ResponderUsageTopic) } }
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
karafka-1.2.13 lib/karafka/schemas/responder_usage.rb
karafka-1.2.12 lib/karafka/schemas/responder_usage.rb
karafka-1.2.11 lib/karafka/schemas/responder_usage.rb
karafka-1.2.10 lib/karafka/schemas/responder_usage.rb
karafka-1.2.9 lib/karafka/schemas/responder_usage.rb
karafka-1.2.8 lib/karafka/schemas/responder_usage.rb
karafka-1.2.7 lib/karafka/schemas/responder_usage.rb
karafka-1.2.6 lib/karafka/schemas/responder_usage.rb
karafka-1.2.5 lib/karafka/schemas/responder_usage.rb
karafka-1.2.4 lib/karafka/schemas/responder_usage.rb
karafka-1.2.3 lib/karafka/schemas/responder_usage.rb
karafka-1.2.2 lib/karafka/schemas/responder_usage.rb
karafka-1.2.1 lib/karafka/schemas/responder_usage.rb
karafka-1.2.0 lib/karafka/schemas/responder_usage.rb
karafka-1.2.0.beta4 lib/karafka/schemas/responder_usage.rb
karafka-1.2.0.beta3 lib/karafka/schemas/responder_usage.rb
karafka-1.2.0.beta2 lib/karafka/schemas/responder_usage.rb
karafka-1.2.0.beta1 lib/karafka/schemas/responder_usage.rb
karafka-1.1.2 lib/karafka/schemas/responder_usage.rb
karafka-1.1.1 lib/karafka/schemas/responder_usage.rb