TypeScript-ready lz4 compression codec for KafkaJS.
ℹ️ Requires Node v10 or above to work.
$ yarn add kafkajs-lz4
import { CompressionTypes, CompressionCodecs } from 'kafkajs';
import LZ4Codec from 'kafkajs-lz4';
CompressionCodecs[CompressionTypes.LZ4] = new LZ4Codec().codec;
All options are transparently passed on to the lz4-asm library's compress options.
To set the highest level of compression for your Kafka messages —
const lz4Codec = new LZ4Codec({
preferences: {
compressionLevel: 16
}
}).codec;
CompressionCodecs[CompressionTypes.LZ4] = lz4Codec;