Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:acrosa/kafka-rb

  • Loading branch information...
commit 32055eeb41b914d5798a90d8483ec84e7f5ae783 2 parents b28f6ce + b668cbd
Ale authored
View
4 lib/kafka/multi_producer.rb
@@ -23,12 +23,12 @@ def initialize(options={})
self.connect(self.host, self.port)
end
- def send(topic, messages, options={})
+ def push(topic, messages, options={})
partition = options[:partition] || 0
self.write(Encoder.produce(topic, partition, messages, compression))
end
- def multi_send(producer_requests)
+ def multi_push(producer_requests)
self.write(Encoder.multiproduce(producer_requests, compression))
end
end
View
4 lib/kafka/producer.rb
@@ -28,14 +28,14 @@ def initialize(options = {})
self.connect(self.host, self.port)
end
- def send(messages)
+ def push(messages)
self.write(Encoder.produce(self.topic, self.partition, messages, compression))
end
def batch(&block)
batch = Kafka::Batch.new
block.call( batch )
- self.send(batch.messages)
+ push(batch.messages)
batch.messages.clear
end
end
View
8 spec/multi_producer_spec.rb
@@ -38,7 +38,7 @@
encoded = Kafka::Encoder.produce("test", 0, message)
subject.should_receive(:write).with(encoded).and_return(encoded.length)
- subject.send("test", message, :partition => 0).should == encoded.length
+ subject.push("test", message, :partition => 0).should == encoded.length
end
it "sends multiple messages" do
@@ -50,7 +50,7 @@
encoded = Encoder.multiproduce(reqs)
subject.should_receive(:write).with(encoded).and_return(encoded.length)
- subject.multi_send(reqs).should == encoded.length
+ subject.multi_push(reqs).should == encoded.length
end
it "should compress messages" do
@@ -60,7 +60,7 @@
encoded = Encoder.produce("test", 0, messages[0])
Encoder.should_receive(:produce).with("test", 0, messages[0], subject.compression).and_return encoded
- subject.send("test", messages[0], :partition => 0)
+ subject.push("test", messages[0], :partition => 0)
reqs = [
Kafka::ProducerRequest.new("topic", messages[0]),
@@ -68,7 +68,7 @@
]
encoded = Encoder.multiproduce(reqs)
Encoder.should_receive(:multiproduce).with(reqs, subject.compression)
- subject.multi_send(reqs)
+ subject.multi_push(reqs)
end
end
end
View
4 spec/producer_spec.rb
@@ -54,14 +54,14 @@
it "should send messages" do
@producer.should_receive(:write).and_return(32)
message = Kafka::Message.new("ale")
- @producer.send(message).should eql(32)
+ @producer.push(message).should eql(32)
end
describe "Message Batching" do
it "should batch messages and send them at once" do
message1 = Kafka::Message.new("one")
message2 = Kafka::Message.new("two")
- @producer.should_receive(:send).with([message1, message2]).exactly(:once).and_return(nil)
+ @producer.should_receive(:push).with([message1, message2]).exactly(:once).and_return(nil)
@producer.batch do |messages|
messages << message1
messages << message2
Please sign in to comment.
Something went wrong with that request. Please try again.