Skip to content

Commit

Permalink
Merge pull request #29 from quiiver/master
Browse files Browse the repository at this point in the history
Add support and test for sending raw buffer messages into BufferMaker
  • Loading branch information
haio committed Mar 26, 2014
2 parents 89e10b5 + 2cdf29e commit d94c079
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/protocol/protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ function encodeMessage(message) {
.Int8(message.attributes)
.Int32BE(message.key.length)
.string(message.key)
.Int32BE(Buffer.byteLength(message.value))
.Int32BE(Buffer.isBuffer(message.value) ? message.value.length : Buffer.byteLength(message.value))
.string(message.value).make();
var crc = crc32.signed(m);
return new Buffermaker()
Expand Down
8 changes: 8 additions & 0 deletions test/test.producer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ describe('Producer', function () {
});
});

it('should send buffer message successfully', function (done) {
var message = new Buffer('hello kafka');
producer.send([{ topic: '_exist_topic_3_test', messages: message }], function (err, message) {
message.should.be.ok;
done(err);
});
});

it('should support multi messages in one topic', function (done) {
producer.send([{ topic: '_exist_topic_3_test', messages: ['hello kafka', 'hello kafka'] }], function (err, message) {
message.should.be.ok;
Expand Down

0 comments on commit d94c079

Please sign in to comment.