Sha256: e8db5a87e7627d95aa4a9bab5f8f9d4afd60c026bb918a682da968f2ddc1f489

Contents?: true

Size: 881 Bytes

Versions: 9

Compression:

Stored size: 881 Bytes

Contents

# frozen_string_literal: true

module WaterDrop
  module Contracts
    # Contract with validation rules for WaterDrop configuration details
    class Config < Dry::Validation::Contract
      # Ensure valid format of each seed broker so that rdkafka doesn't fail silently
      SEED_BROKER_FORMAT_REGEXP = %r{\A([^:/,]+:[0-9]+)(,[^:/,]+:[0-9]+)*\z}.freeze

      private_constant :SEED_BROKER_FORMAT_REGEXP

      params do
        required(:id).filled(:str?)
        required(:logger).filled
        required(:deliver).filled(:bool?)
        required(:max_payload_size).filled(:int?, gteq?: 1)
        required(:max_wait_timeout).filled(:number?, gteq?: 0)
        required(:wait_timeout).filled(:number?, gt?: 0)

        required(:kafka).schema do
          required(:'bootstrap.servers').filled(:str?, format?: SEED_BROKER_FORMAT_REGEXP)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
waterdrop-2.1.0 lib/water_drop/contracts/config.rb
waterdrop-2.0.7 lib/water_drop/contracts/config.rb
waterdrop-2.0.6 lib/water_drop/contracts/config.rb
waterdrop-2.0.5 lib/water_drop/contracts/config.rb
waterdrop-2.0.4 lib/water_drop/contracts/config.rb
waterdrop-2.0.3 lib/water_drop/contracts/config.rb
waterdrop-2.0.2 lib/water_drop/contracts/config.rb
waterdrop-2.0.1 lib/water_drop/contracts/config.rb
waterdrop-2.0.0 lib/water_drop/contracts/config.rb