Include snappy compression (or working example)
See original GitHub issueHi,
Tried to do it myself according to example from readme.md, but hitting “Invalid input” error.
So it would be usefull to have either built in support (auto-detecting snappy module presence if don’t want to include c++ dependency) or at least working example in /examples folder.
My code:
//snappy-compression.js
var snappy = require('snappy');
const { promisify } = require('util');
const snappyCompress = promisify(snappy.compress)
const snappyDecompress = promisify(snappy.uncompress)
module.exports = {
async compress(encoder) {
return await snappyCompress(encoder.buffer)
},
async decompress(buffer) {
return await snappyDecompress(buffer)
}
}
//index.js
const { Kafka, logLevel, CompressionTypes, CompressionCodecs } = require('kafkajs')
CompressionCodecs[CompressionTypes.Snappy] = () => require('./snappy-compression');
// Create the client with the broker list
const kafka = new Kafka({...
I see data arriving on INFO level logs, snappy decompress run but unable to decompress the buffer.
{"level":"DEBUG","timestamp":"2018-08-24T19:39:21.578Z","logger":"kafkajs","message":"[Connection] Response Fetch(key: 1, version: 3)","broker":"IP.IP.IP.IP:9092","clientId":"kafkajs-app","error":"Invalid input","correlationId":3,"payload":{"type":"Buffer","data":[0,0,0,0,0,0,0,1,0,19,100,101,98,101,122,105,117,109,45,104,101,97,114...
Using kafka 1.1, producing data with java client
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
What is Google Snappy? High-speed data compression and ...
While Snappy compression is faster, you might need to factor in slightly higher storage costs. Your files at rest will be bigger with...
Read more >Snappy (compression) - Wikipedia
Snappy (previously known as Zippy) is a fast data compression and decompression library written in C++ by Google based on ideas from LZ77...
Read more >snappy | A fast compressor/decompressor - Google
Snappy is a compression/decompression library. It does not aim for maximum compression, or compatibility with any other compression library; instead, it aims ...
Read more >Snappy compression for Windows - Snappy for Windows
Snappy is a compression/decompression library. It does not aim for maximum compression, or compatibility with any other compression library; instead, it aims ...
Read more >Snappy Compression | 6.3.x - Cloudera Documentation
Snappy is ideal in this case because it compresses and decompresses very quickly compared to other compression algorithms, such as Gzip. For ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I moved my gist to an NPM package https://www.npmjs.com/package/kafkajs-snappy
I’ll update the readme later
I get TypeError: codec is not a function when I try to use kafkajs-snappy as intended, by the way.