Sha256: 1177f797967c05ffd2a14f36d46fc4f2b797d883ad4d76f47dc7cd49e26664ba

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module Racecar
  class Consumer
    Subscription = Struct.new(:topic, :start_from_beginning, :max_bytes_per_partition)

    class << self
      attr_accessor :max_wait_time
      attr_accessor :group_id

      def subscriptions
        @subscriptions ||= []
      end

      # Adds one or more topic subscriptions.
      #
      # start_from_beginning    - whether to start from the beginning or the end of each
      #                           partition.
      # max_bytes_per_partition - the maximum number of bytes to fetch from each partition
      #                           at a time.
      def subscribes_to(*topics, start_from_beginning: true, max_bytes_per_partition: 1048576)
        topics.each do |topic|
          subscriptions << Subscription.new(topic, start_from_beginning, max_bytes_per_partition)
        end
      end
    end

    def configure(producer:)
      @_producer = producer
    end

    def teardown; end

    protected

    def produce(value, **options)
      @_producer.produce(value, **options)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
racecar-0.3.7 lib/racecar/consumer.rb