-
Notifications
You must be signed in to change notification settings - Fork 12
Adding ability to compress data when delivering to firehose #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -311,7 +311,7 @@ module.exports = function(configure) { | |
| } | ||
| done(null, e); | ||
| })); | ||
| if (opts.useS3 && !opts.firehose) { | ||
| if (opts.useS3) { | ||
| args.push(leoS3(ls, outQueue, configure, { prefix: opts.prefix || id, ...opts.s3Opts })); | ||
| } else if (!opts.firehose) { | ||
| // TODO: This should be part of auto switch | ||
|
|
@@ -696,7 +696,7 @@ module.exports = function(configure) { | |
| } | ||
| }; | ||
| var type = "kinesis"; | ||
| if (opts.useS3 && !opts.firehose) { //why would both of these be set? | ||
| if (opts.useS3) { | ||
| type = "s3"; | ||
| } else if (opts.firehose) { | ||
| type = "firehose"; | ||
|
|
@@ -766,7 +766,7 @@ module.exports = function(configure) { | |
| logger.time("firehose request"); | ||
| firehose.putRecordBatch({ | ||
| Records: [{ | ||
| Data: records.join('') | ||
| Data: opts.gzipFirehose ? (records.map(r => r.toString("base64")).join('\n') + '\n') : records.join('') | ||
| }], | ||
| DeliveryStreamName: configure.bus.firehose | ||
| }, function(err, data) { | ||
|
|
@@ -850,13 +850,13 @@ module.exports = function(configure) { | |
| enableLogging: true, | ||
| snapshot: opts.snapshot | ||
| }, opts.chunk || {}); | ||
| chunkOpts.gzip = !opts.firehose; | ||
| chunkOpts.gzip = opts.gzipFirehose || !opts.firehose; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @czirker Or is that what this does? The chunker does the gzipping?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. The chunker will do the zipping. The user just needs to specify that they want to enable the feature using |
||
|
|
||
| let currentQueues = new Set(); | ||
| var p = ls.buffer(opts, function(obj, callback) { | ||
| if (obj.stats) { | ||
| Object.values(obj.stats).map(v => { | ||
| let queues = v.queues; | ||
| let queues = v.queues || {}; | ||
| // We don't want queues to continue past here, so remove it | ||
| delete v.queues; | ||
| return Object.keys(queues); | ||
|
|
@@ -867,7 +867,12 @@ module.exports = function(configure) { | |
| if (obj.gzip) { | ||
| records.push(obj.gzip); | ||
| } else if (obj.s3) { | ||
| records.push(zlib.gzipSync(JSON.stringify(obj) + "\n")); | ||
| let data = JSON.stringify(obj) + "\n"; | ||
| if (chunkOpts.gzip) { | ||
| records.push(zlib.gzipSync(data)); | ||
| } else { | ||
| records.push(data); | ||
| } | ||
| } | ||
| } | ||
| if (obj.correlations) { | ||
|
|
@@ -888,7 +893,7 @@ module.exports = function(configure) { | |
| }); | ||
|
|
||
| let streams = []; | ||
| if (!opts.useS3 && !opts.firehose) { | ||
| if (!opts.useS3) { | ||
| streams.push(ls.throughAsync(async (obj, push) => { | ||
| let size = Buffer.byteLength(JSON.stringify(obj)); | ||
| if (size > twoHundredK * 3) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@czirker Are we expecting the person using this to be gzipping the content themselves?