Comparing version 1.2.1 to 1.2.2
@@ -94,2 +94,3 @@ 'use strict'; | ||
} | ||
return null; | ||
}); | ||
@@ -96,0 +97,0 @@ }) |
@@ -494,10 +494,10 @@ 'use strict'; | ||
Client.prototype.listGroupsRequest = function () { | ||
var self = this; | ||
var self = this, buffer; | ||
var buffer = self.protocol.write().ListGroupsRequest({ | ||
correlationId: self.correlationId++, | ||
clientId: self.options.clientId | ||
}).result; | ||
return self._metadata().then(function () { | ||
buffer = self.protocol.write().ListGroupsRequest({ | ||
correlationId: self.correlationId++, | ||
clientId: self.options.clientId | ||
}).result; | ||
return self._metadata().then(function () { | ||
return Promise.map(_.values(self.brokerConnections), function (connection) { | ||
@@ -514,15 +514,13 @@ return connection.send(buffer).then(function (responseBuffer) { | ||
return self._metadata().then(function () { | ||
return self._findGroupCoordinator(groupId).then(function (connection) { | ||
var buffer = self.protocol.write().DescribeGroupRequest({ | ||
correlationId: self.correlationId++, | ||
clientId: self.options.clientId, | ||
groups: [groupId] | ||
}).result; | ||
return self._findGroupCoordinator(groupId).then(function (connection) { | ||
var buffer = self.protocol.write().DescribeGroupRequest({ | ||
correlationId: self.correlationId++, | ||
clientId: self.options.clientId, | ||
groups: [groupId] | ||
}).result; | ||
return connection.send(buffer).then(function (responseBuffer) { | ||
return self.protocol.read(responseBuffer).DescribeGroupResponse().result.groups[0]; | ||
}); | ||
return connection.send(buffer).then(function (responseBuffer) { | ||
return self.protocol.read(responseBuffer).DescribeGroupResponse().result.groups[0]; | ||
}); | ||
}); | ||
}; |
@@ -95,3 +95,5 @@ 'use strict'; | ||
Connection.prototype.close = function () { | ||
this._disconnect({ _kafka_connection_closed: true }); | ||
var err = new NoKafkaConnectionError(this, 'Connection closed'); | ||
err._kafka_connection_closed = true; | ||
this._disconnect(err); | ||
}; | ||
@@ -98,0 +100,0 @@ |
@@ -76,3 +76,3 @@ 'use strict'; | ||
if (attempt > 3) { | ||
throw new Error('Failed to join the group'); | ||
throw new Error('Failed to join the group: GroupCoordinatorNotAvailable'); | ||
} | ||
@@ -313,3 +313,3 @@ | ||
}); | ||
})() | ||
}()) | ||
.catch(function (err) { | ||
@@ -322,2 +322,1 @@ self.client.error('Failed to subscribe to', p.topic + ':' + p.partition, err); | ||
}; | ||
@@ -97,2 +97,2 @@ 'use strict'; | ||
return exports; | ||
})(); | ||
}()); |
@@ -9,3 +9,3 @@ { | ||
}, | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"main": "./lib/index.js", | ||
@@ -23,8 +23,8 @@ "keywords": ["kafka"], | ||
"devDependencies": { | ||
"mocha": "~=2.3.4", | ||
"chai": "~=3.4.1", | ||
"sinon-chai": "~=2.8.0", | ||
"chai-as-promised": "~=5.1.0", | ||
"mocha": "^2.4.5", | ||
"chai": "^3.5.0", | ||
"sinon-chai": "^2.8.0", | ||
"chai-as-promised": "^5.2.0", | ||
"eslint": "^1.10.3", | ||
"eslint-config-airbnb": "^3.1.0", | ||
"eslint-config-airbnb": "^5.0.0", | ||
"istanbul": "^0.4.2" | ||
@@ -31,0 +31,0 @@ }, |
@@ -1,2 +0,4 @@ | ||
[![Build Status](https://travis-ci.org/oleksiyk/kafka.png)](https://travis-ci.org/oleksiyk/kafka) | ||
[![Build Status](https://travis-ci.org/oleksiyk/kafka.svg)](https://travis-ci.org/oleksiyk/kafka) | ||
[![Dependencies](https://david-dm.org/oleksiyk/kafka.svg)](https://david-dm.org/oleksiyk/kafka) | ||
[![DevDependencies](https://david-dm.org/oleksiyk/kafka/dev-status.svg)](https://david-dm.org/oleksiyk/kafka#info=devDependencies) | ||
@@ -72,3 +74,3 @@ # no-kafka | ||
```javascript | ||
consumer.subscribe('kafka-test-topic', 0, {offset: 20, maxBytes: 30} | ||
consumer.subscribe('kafka-test-topic', 0, {offset: 20, maxBytes: 30}) | ||
``` | ||
@@ -78,4 +80,4 @@ | ||
```javascript | ||
consumer.subscribe('kafka-test-topic', 0, {time: Kafka.LATEST_OFFSET} | ||
consumer.subscribe('kafka-test-topic', 0, {time: Kafka.EARLIEST_OFFSET} | ||
consumer.subscribe('kafka-test-topic', 0, {time: Kafka.LATEST_OFFSET}) | ||
consumer.subscribe('kafka-test-topic', 0, {time: Kafka.EARLIEST_OFFSET}) | ||
``` | ||
@@ -179,3 +181,3 @@ | ||
}; | ||
// consumer.init(strategy).... | ||
// consumer.init(strategies).... | ||
``` | ||
@@ -194,3 +196,3 @@ | ||
}; | ||
// consumer.init(strategy).... | ||
// consumer.init(strategies).... | ||
``` | ||
@@ -205,3 +207,3 @@ Note that each consumer in a group should have its own and consistent metadata.id. | ||
}; | ||
// consumer.init(strategy).... | ||
// consumer.init(strategies).... | ||
``` | ||
@@ -208,0 +210,0 @@ |
24
test.js
'use strict'; | ||
var _ = require('lodash'); | ||
var Kafka = require('./lib'); | ||
var r = _([1, 2]).toString(); | ||
var consumer = new Kafka.GroupConsumer({ | ||
}); | ||
console.log(r); | ||
var strategies = { | ||
strategy: 'TestStrategy', | ||
subscriptions: ['kafka-test-topic-1'] | ||
}; | ||
var target = {}; | ||
consumer.on('data', function (messageSet, topic, partition) { | ||
messageSet.forEach(function (m) { | ||
console.log(topic, partition, m.offset, m.message.value.toString('utf8')); | ||
// process each message and commit its offset | ||
consumer.commitOffset({ topic: topic, partition: partition, offset: m.offset, metadata: 'optional' }); | ||
}); | ||
}); | ||
_.merge(target, { | ||
buffer: new Buffer([0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80]) | ||
return consumer.init(strategies).then(function () { | ||
// all done, now wait for messages in event listener | ||
}); | ||
console.log(target); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
174771
3324
318