smithy-lang / smithy-python

Smithy code generators and core modules for Python (in development)
Apache License 2.0
48 stars 10 forks source link

Add AWS event stream serde support #302

Closed JordonPhillips closed 2 months ago

JordonPhillips commented 2 months ago

This adds support for serializing and deserializing the application/vnd.amazon.eventstream format for event stream framing. This adds both high-level support useable in any context and codec serde support.

This could still use some tests, but much of that will come in the way of event stream protocol tests.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

JordonPhillips commented 2 months ago

Do we have any plans for more functional testing or do you see that living in a generated clients package?

Yes, much more. What's here now is basically just the test cases that exist in the application/vnd.amazon.eventstream spec, which certainly isn't enough.

JordonPhillips commented 2 months ago

This is out of draft and ready for review.

The one potentially controversial decision I made was around integer headers. There's a few types to indicate the size of the int since it's important for the wire format. The potentially controversial bit is that these are only used when serializing headers from a dict. They notably are not returned in deserialization.

I did this because I don't want to be propagating those types into clients, and I don't want to have to cast them away all the time. From the perspective of most consumers, I don't think it should be a problem, because who cares about integer size in python anyway. And realistically, few consumers will ever be using the event utilities directly anyway.

If it's something people ask for, we could always make it a toggle or something.