Skip to content

indix/kafkajs-lz4

Repository files navigation

kafkajs-lz4

Build Status NPM Version

TypeScript-ready lz4 compression codec for KafkaJS.

ℹ️ Requires Node v10 or above to work.

Install

$ yarn add kafkajs-lz4

Usage

import { CompressionTypes, CompressionCodecs } from 'kafkajs';
import LZ4Codec from 'kafkajs-lz4';

CompressionCodecs[CompressionTypes.LZ4] = new LZ4Codec().codec;

Options

All options are transparently passed on to the lz4-asm library's compress options.

Example

To set the highest level of compression for your Kafka messages —

const lz4Codec = new LZ4Codec({
    preferences: {
        compressionLevel: 16
    }
}).codec;

CompressionCodecs[CompressionTypes.LZ4] = lz4Codec;