Sha256: d726aa444f6d2bbf727178fc1cffd9f5c615f1e6f2da97429eb2389a801a1536

Contents?: true

Size: 864 Bytes

Versions: 8

Compression:

Stored size: 864 Bytes

Contents

module Deimos
  class ProducerRoute < Karafka::Routing::Features::Base
    FIELDS = %i(producer_classes payload_log disabled)

    Config = Struct.new(*FIELDS, keyword_init: true) do
      def producer_class=(val)
        self.producer_classes = [val]
      end

      def producer_class
        self.producer_classes.first
      end
    end
    module Topic
      (FIELDS + [:producer_class]).each do |field|
        define_method(field) do |*args|
          active(false) if %i(producer_class producer_classes).include?(field)
          @deimos_producer_config ||= Config.new
          if args.any?
            @deimos_producer_config.public_send("#{field}=", args[0])
            _deimos_setup_transcoders if schema && namespace
          end
          @deimos_producer_config.send(field)
        end
      end
    end
  end
end

Deimos::ProducerRoute.activate

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
deimos-ruby-2.0.0.pre.beta3 lib/deimos/ext/producer_route.rb
deimos-ruby-2.0.0.pre.beta2 lib/deimos/ext/producer_route.rb
deimos-ruby-2.0.0.pre.beta1 lib/deimos/ext/producer_route.rb
deimos-ruby-2.0.0.pre.alpha7 lib/deimos/ext/producer_route.rb
deimos-ruby-2.0.0.pre.alpha6 lib/deimos/ext/producer_route.rb
deimos-ruby-2.0.0.pre.alpha5 lib/deimos/ext/producer_route.rb
deimos-ruby-2.0.0.pre.alpha4 lib/deimos/ext/producer_route.rb
deimos-ruby-2.0.0.pre.alpha3 lib/deimos/ext/producer_route.rb