From 5b365981625964aa609f80fa622a0372d558a368 Mon Sep 17 00:00:00 2001 From: tulios Date: Sat, 23 Jun 2018 22:34:55 +0200 Subject: [PATCH] Add support for Record Batch compression codec flag --- src/protocol/message/compression/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/protocol/message/compression/index.js b/src/protocol/message/compression/index.js index ae015f86f..9ca8c8261 100644 --- a/src/protocol/message/compression/index.js +++ b/src/protocol/message/compression/index.js @@ -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, @@ -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 } @@ -28,4 +35,5 @@ module.exports = { Codecs, lookupCodec, lookupCodecByAttributes, + lookupCodecByRecordBatchAttributes, }