diff --git a/lib/fake/kafka.rb b/lib/fake/kafka.rb index accf811..d7682d9 100644 --- a/lib/fake/kafka.rb +++ b/lib/fake/kafka.rb @@ -1,12 +1,10 @@ require 'fake/kafka/version' require 'fake/kafka/consumer' require 'fake/kafka/producer' -#require 'fake/kafka/message' +require 'fake/kafka/message' module Fake class Kafka - FakeMessage = Struct.new(:value, :key, :topic, :partition, :offset) - # Your code goes here... attr_reader :messages, :paused_partitions def initialize(*options) @@ -20,7 +18,7 @@ def paused?(topic, partition) end def deliver_message(value, topic:) - @messages << FakeMessage.new(value, nil, topic, 0, 0) + @messages << Message.new(value, nil, topic, 0, 0) end def messages_in(topic) diff --git a/lib/fake/kafka/message.rb b/lib/fake/kafka/message.rb new file mode 100644 index 0000000..5ec3d13 --- /dev/null +++ b/lib/fake/kafka/message.rb @@ -0,0 +1,14 @@ +class Fake::Kafka::Message + attr_reader :key, :topic, :partition, :offset + def initialize(value, key, topic, partition, offset) + @value = value + @key = key + @topic = topic + @partition = partition + @offset = offset + end + + def value + @value.to_json + end +end