Comments (5)
I'll try to take a look when I get a chance, but in the meantime, I think this unit test does exactly the thing you're trying to do:
https://github.com/awslabs/kinesis-aggregation/blob/master/python/test/test_end_to_end.py#L101
Let me know if you spot the difference. Otherwise I'll try to take a look later on.
from kinesis-aggregation.
OK, I had a bit more time to look...
The issue is that the deaggregate_records
call is not set up to take a byte string, which is what the code is currently passing it. It expects the input is a list of record json objects as returned by events received by an AWS Lambda function (see https://github.com/awslabs/kinesis-aggregation/blob/master/python/lambda_function.py#L21 for an example). You can see a sample of this JSON format here: https://github.com/awslabs/kinesis-aggregation/blob/master/python/test/test_end_to_end.py#L25:
To make the code work, something like this should do it:
from aws_kinesis_agg.aggregator import RecordAggregator
from aws_kinesis_agg.deaggregator import deaggregate_records
import base64
import uuid
import json
aggregator = RecordAggregator()
result = None
while result is None:
record = {"key": "value"}
rec = json.dumps(record)
result = aggregator.add_user_record(str(uuid.uuid4()), rec)
raw_record = result.get_contents()[-1]
#NOTE: There are more fields, but these are the only required ones
record_list = [{ "kinesis" : { "data" : base64.b64encode(raw_record), "kinesisSchemaVersion": "1.0", "sequenceNumber": "0"} } ]
records = deaggregate_records(record_list)
I hope that helps!
from kinesis-aggregation.
Thanks for the reply, that makes sense, I will try that out.
I do think that it would make sense for the desegregation method to recognize the aggregated record that can be generated by this module and also be able to handle it.
from kinesis-aggregation.
As I was writing that code, I could definitely see how what you wrote originally seemed like it should work. It's not the most straightforward API by any means.
I think the history of it is that the Kinesis Client Library and the Kinesis Multilang Daemon existed already to do the direct translation and so this package was initially focused on dealing with Lambda-specific situations where the KCL might not be applicable.
That being said, I think I'm with you. There's no reason we couldn't make some wrapper functions that do exactly what my code sample did to your original code sample.
Do you think we should keep this issue open or create a new one?
from kinesis-aggregation.
I think just keep this issue open, I think a new issue would be superfluous.
from kinesis-aggregation.
Related Issues (20)
- Aggregation in Java combines different partition keys to one request HOT 1
- Size or time in seconds for trigger callback HOT 1
- Not able to specify 'Boto3' as a keyword argument for iter_deaggregate_records HOT 2
- Need parameter data_format in definition for deaggregate_records to use with Boto3
- AggRecord does not validate record size correctly HOT 3
- aws_kinesis_agg not supported in FIPS mode HOT 1
- Unnecessary dependence on the `npm` package
- Feature request: Provide language support for rustlang
- Provide .protobuf file to allow code generation for non-supported languages HOT 1
- kpl_pb2.py should be regenerated to avoid problems with upcoming protobuf release HOT 11
- Documentation mentions using AggregationManager, which does not exist HOT 4
- Incomplete Documentation - 404 for link
- Is data loss possible when consume aggregated records by AWS lambda? HOT 11
- aws-kinesis-agg nodejs 18 + support HOT 1
- package.json version bump
- Aws-SDK-V3 support HOT 2
- Feature Request: Support for non-MD5 hashing HOT 3
- aws_kinesis_agg fails to run on FIPS compliant python images HOT 1
- CVE-2023-36665
- protobufjs Prototype Pollution vulnerability HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kinesis-aggregation.