Sha256: 01eacd097799fb80542fc61753054b90bbbc560e524762255cdbeb53e8033acb

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

# External components
%w[
  json
  delivery_boy
  null_logger
  singleton
  dry-configurable
  dry/monitor/notifications
  dry-validation
].each { |lib| require lib }

# Internal components
base_path = File.dirname(__FILE__) + '/water_drop'

# WaterDrop library
module WaterDrop
  class << self
    attr_accessor :logger

    # Sets up the whole configuration
    # @param [Block] block configuration block
    def setup(&block)
      Config.setup(&block)

      DeliveryBoy.logger = self.logger = config.logger

      # Recursive lambda for mapping config down to delivery boy
      applier = lambda { |db_config, h|
        h.each do |k, v|
          applier.call(db_config, v) && next if v.is_a?(Hash)
          next unless db_config.respond_to?(:"#{k}=")
          db_config.public_send(:"#{k}=", v)
        end
      }

      DeliveryBoy.config.tap do |config|
        config.brokers = Config.config.kafka.seed_brokers
        applier.call(config, Config.config.to_h)
      end
    end

    # @return [WaterDrop::Config] config instance
    def config
      Config.config
    end

    # @return [::WaterDrop::Monitor] monitor that we want to use
    def monitor
      config.monitor
    end

    # @return [String] root path of this gem
    def gem_root
      Pathname.new(File.expand_path('..', __dir__))
    end
  end
end

%w[
  version
  instrumentation/monitor
  instrumentation/listener
  schemas/message_options
  schemas/config
  config
  errors
  base_producer
  sync_producer
  async_producer
].each { |lib| require "#{base_path}/#{lib}" }

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
waterdrop-1.2.1 lib/water_drop.rb