Sha256: 01315f966a72d7a0daf6576ea4b1a005130543bf492b7ae21e6b7399b65db3bd

Contents?: true

Size: 622 Bytes

Versions: 9

Compression:

Stored size: 622 Bytes

Contents

require 'kafka_session/delivered_message'

class KafkaSession
  class MockProducer
    def initialize
      @messages_by_topic = Hash.new { |messages, topic| messages[topic] = [] }
    end

    def publish(topic:, messages:)
      messages.each do |message|
        @messages_by_topic[topic] << OpenStruct.new(
          value:     message,
          topic:     topic,
          partition: 1,
          offset:    100,
          key:       nil
        )
      end
    end

    def messages_for_topic(topic)
      @messages_by_topic[topic].map do |message|
        DeliveredMessage.new(message)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
kafka_session-0.5.0 lib/kafka_session/mock_producer.rb
kafka_session-0.4.1 lib/kafka_session/mock_producer.rb
kafka_session-0.4.0 lib/kafka_session/mock_producer.rb
kafka_session-0.4.0.pre.alpha lib/kafka_session/mock_producer.rb
kafka_session-0.3.1 lib/kafka_session/mock_producer.rb
kafka_session-0.3.0 lib/kafka_session/mock_producer.rb
kafka_session-0.2.1 lib/kafka_session/mock_producer.rb
kafka_session-0.2.0 lib/kafka_session/mock_producer.rb
kafka_session-0.1.0 lib/kafka_session/mock_producer.rb