(cb)
| 123 | } |
| 124 | |
| 125 | commit (cb) { |
| 126 | let self = this; |
| 127 | |
| 128 | if (!cb) { |
| 129 | cb = function noop () {}; |
| 130 | } |
| 131 | |
| 132 | if (self.committing) { |
| 133 | return cb(null, 'Commit in progress'); |
| 134 | } |
| 135 | |
| 136 | let topicPartionOffsets = self.topicPartionOffsets; |
| 137 | |
| 138 | let commits = topicPartionOffsets.filter(function (partition) { |
| 139 | return partition.offset !== 0; |
| 140 | }); |
| 141 | |
| 142 | if (commits.length) { |
| 143 | self.committing = true; |
| 144 | self.client.sendOffsetCommitRequest(self.groupId, commits, function () { |
| 145 | self.emit('commitComplete', { group: self.groupId, commits }); |
| 146 | self.committing = false; |
| 147 | cb.apply(this, arguments); |
| 148 | }); |
| 149 | } else { |
| 150 | cb(null, 'Nothing to be committed'); |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | module.exports = CommitStream; |
no test coverage detected