kafka-node
Advanced tools
Comparing version 1.0.2 to 1.0.3
# kafka-node CHANGELOG | ||
## 2016-10-24, Version 1.0.3 | ||
- Fix issue in [Consumer Group](https://github.com/SOHU-Co/kafka-node#consumergroup) where using the migrator with no previous HLC offsets will set initial offsets to 0 instead of the offsets provided in "fromOfset" feature [#493](https://github.com/SOHU-Co/kafka-node/pull/493) | ||
## 2016-10-22, Version 1.0.2 | ||
@@ -4,0 +7,0 @@ - Fix issue in [Consumer Group](https://github.com/SOHU-Co/kafka-node#consumergroup) where using the migrator with no previous HLC offsets will set initial offsets to -1 [#490](https://github.com/SOHU-Co/kafka-node/pull/490) |
@@ -148,3 +148,3 @@ 'use strict'; | ||
} | ||
self.offsets = _.mapValues(results, topic => _.mapValues(topic, value => value === -1 ? 0 : value)); | ||
self.offsets = results; | ||
callback(null); | ||
@@ -155,5 +155,9 @@ }); | ||
ConsumerGroupMigrator.prototype.getOffset = function (tp, defaultOffset) { | ||
return _.get(this.offsets, [tp.topic, tp.partition], defaultOffset); | ||
const offset = _.get(this.offsets, [tp.topic, tp.partition], defaultOffset); | ||
if (offset === -1) { | ||
return defaultOffset; | ||
} | ||
return offset; | ||
}; | ||
module.exports = ConsumerGroupMigrator; |
@@ -12,3 +12,3 @@ { | ||
"bugs": "https://github.com/SOHU-co/kafka-node/issues", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"main": "kafka.js", | ||
@@ -15,0 +15,0 @@ "license": "MIT", |
@@ -8,3 +8,3 @@ 'use strict'; | ||
describe('ConsumerGroupMigrator', function () { | ||
describe('#saveHighLevelConsumerOffsets', function () { | ||
describe('#saveHighLevelConsumerOffsets and #getOffset', function () { | ||
it('saves HLC offsets and maps offsets with -1 to 0', function (done) { | ||
@@ -33,6 +33,6 @@ const fakeClient = new EventEmitter(); | ||
migrator.saveHighLevelConsumerOffsets(['TestTopic', 'TestEvent'], function (error) { | ||
migrator.getOffset({topic: 'TestTopic', partition: 0}, -1).should.be.eql(0); | ||
migrator.getOffset({topic: 'TestTopic', partition: 1}, -1).should.be.eql(0); | ||
migrator.getOffset({topic: 'TestTopic', partition: 2}, -1).should.be.eql(10); | ||
migrator.getOffset({topic: 'TestEvent', partition: 0}, -1).should.be.eql(0); | ||
migrator.getOffset({topic: 'TestTopic', partition: 0}, 0).should.be.eql(0); | ||
migrator.getOffset({topic: 'TestTopic', partition: 1}, 23).should.be.eql(0); | ||
migrator.getOffset({topic: 'TestTopic', partition: 2}, 128).should.be.eql(10); | ||
migrator.getOffset({topic: 'TestEvent', partition: 0}, 4).should.be.eql(4); | ||
migrator.getOffset({topic: 'TestEvent', partition: 1}, 222).should.be.eql(222); | ||
@@ -39,0 +39,0 @@ done(error); |
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
346778
8394