Skip to content

Commit

Permalink
Fix issue where KafkaClient ready flag was not set to true after succ…
Browse files Browse the repository at this point in the history
…essful connection
  • Loading branch information
hyperlink committed Jul 5, 2017
1 parent 14b65e6 commit 05743a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/kafkaClient.js
Expand Up @@ -129,6 +129,7 @@ KafkaClient.prototype.connect = function () {
return this.emit('error', error);
}
this.updateMetadatas(result);
this.ready = true;
this.emit('ready');
});
});
Expand Down
3 changes: 3 additions & 0 deletions test/test.kafkaClient.js
Expand Up @@ -195,6 +195,7 @@ describe('Kafka Client', function () {
client.once('error', done);
client.once('ready', function () {
client.brokerMetadata.should.not.be.empty;
client.ready.should.be.true;
done();
});
});
Expand All @@ -208,6 +209,7 @@ describe('Kafka Client', function () {
});

client.on('error', function (error) {
client.ready.should.be.false;
error.code.should.be.eql('ECONNREFUSED');
done();
});
Expand All @@ -222,6 +224,7 @@ describe('Kafka Client', function () {
});
client.once('error', done);
client.once('ready', function () {
client.ready.should.be.true;
client.brokerMetadata.should.not.be.empty;
done();
});
Expand Down

0 comments on commit 05743a4

Please sign in to comment.