-
Notifications
You must be signed in to change notification settings - Fork 406
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
feat(parser): add KafkaMskEventModel and KafkaSelfManagedEventModel #1499
Conversation
i think there's something with spaces/ \n in 2 files for some reason |
Hi @ran-isenberg. Thank you very much for submitting this PR to improve the parser features. We were working on #1485 to make sure we had consistency in the fields and nothing was missing. At first glance, I think we need to change things up in this PR. 1 - I can't see the eventSourceArn field. This is mandatory when the event source comes from MSK. Feel free to ping me on Discord if you want. Leandro |
@leandrodamascena |
@leandrodamascena pushed the fixes |
@heitorlessa @leandrodamascena added some data class kafka docs fixes |
Hi @ran-isenberg! Answering your question: yes, we think it makes sense to keep the Kafka envelope to extract the logs from the record. We believe it makes the code cleaner and we follow the same one we used in Kinesis, for example. Could you please rebase the repository locally and just send the code related to this PR? For some reason this PR came with previous changes to github actions and this makes it a little difficult to read the PR and understand everything that is being changed. I will make considerations that we could consider changing before merging this PR. But as I see, this is a nice feature to parser events from Kafka. Thanks 🚀 |
take a look now ;) |
you might notice that there's a clear distinction between the two kafka events, unlike data classes, which is what i'd expect from a parser. |
Yes, I've seen that and it makes it clearer events from selfManaged and MSK. I'll open a issue to split the data classes into 2 events, just like the parser. 🏅 |
Codecov Report
@@ Coverage Diff @@
## develop #1499 +/- ##
===========================================
- Coverage 99.48% 99.42% -0.07%
===========================================
Files 126 128 +2
Lines 5672 5743 +71
Branches 661 670 +9
===========================================
+ Hits 5643 5710 +67
- Misses 14 18 +4
Partials 15 15
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
|
||
|
||
class KafkaBaseEventModel(BaseModel): | ||
bootstrapServers: Optional[List[str]] |
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.
This field is not optional. So, we must remove the Optional
. Even the AWS documentation here doesn't mention the bootstrapServers field, I created an MSK cluster and added it as an event source of a Lambda and I was able to confirm that the bootstrapServers field is also present there.
I've notified the documentation team to include it.
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.
np, will fix it
def _base64_decode(value: str) -> bytes: | ||
try: | ||
logger.debug("Decoding base64 Kafka record item before parsing") | ||
return base64.b64decode(value) | ||
except (BinAsciiError, TypeError): | ||
raise ValueError("base64 decode failed") | ||
|
||
|
||
def _bytes_to_string(value: bytes) -> str: | ||
try: | ||
return value.decode("utf-8") | ||
except (BinAsciiError, TypeError): | ||
raise ValueError("base64 UTF-8 decode failed") |
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.
As we are adding new features and always improving our code, what do you think about moving these 2 functions to the shared functions file?
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.
sure, np
Co-authored-by: Leandro Damascena <leandro.damascena@gmail.com>
Co-authored-by: Leandro Damascena <leandro.damascena@gmail.com>
Co-authored-by: Leandro Damascena <leandro.damascena@gmail.com>
@leandrodamascena all fixed |
Thanks for addressing all changes very quickly! I made some minor changes to change the Hi @heitorlessa, could you please take a look here? I would like to have a double check on this. |
Hi @ran-isenberg! If you have no other considerations, it's okay to merge this PR. Thanks again for helping to improve the project. 🚀 |
sure, thx for the changes. |
…1499) Co-authored-by: Leandro Damascena <leandro.damascena@gmail.com> Co-authored-by: Heitor Lessa <lessa@amazon.com> Co-authored-by: heitorlessa <lessa@amazon.co.uk> Co-authored-by: Release bot <aws-devax-open-source@amazon.com> Co-authored-by: Peter Schutt <peter@schutt.io> Co-authored-by: Ran Isenberg <ran.isenberg@ranthebuilder.cloud> Co-authored-by: Ran Isenberg <ran.isenberg@cyberark.com>
Issue number: #1498
Summary
parser support for kafka swelf managed events to lambda.
TBH still debating if the envelope is really useful, i think in most cases people should extend kafkamodel class and use it instead.
Changes
added envelope, models, tests docs.
User experience
see #1498
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.
View rendered CHANGELOG.md
View rendered docs/core/event_handler/api_gateway.md
View rendered docs/utilities/parser.md