Skip to content

Commit

Permalink
Add support for Record Batch compression codec flag
Browse files Browse the repository at this point in the history
  • Loading branch information
tulios committed Jun 23, 2018
1 parent 2c60e74 commit 5b36598
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/protocol/message/compression/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const { KafkaJSNotImplemented } = require('../../../errors')

const MESSAGE_CODEC_MASK = 0x3
const RECORD_BATCH_CODEC_MASK = 0x07

const Types = {
None: 0,
GZIP: 1,
Expand All @@ -19,7 +22,11 @@ const Codecs = {

const lookupCodec = type => (Codecs[type] ? Codecs[type]() : null)
const lookupCodecByAttributes = attributes => {
const codec = Codecs[attributes & 0x3]
const codec = Codecs[attributes & MESSAGE_CODEC_MASK]
return codec ? codec() : null
}
const lookupCodecByRecordBatchAttributes = attributes => {
const codec = Codecs[attributes & RECORD_BATCH_CODEC_MASK]
return codec ? codec() : null
}

Expand All @@ -28,4 +35,5 @@ module.exports = {
Codecs,
lookupCodec,
lookupCodecByAttributes,
lookupCodecByRecordBatchAttributes,
}

0 comments on commit 5b36598

Please sign in to comment.