add initial support for streaming in ASF scaffold and serializer #6086
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds initial support for event streaming to the ASF scaffold (for the generated APIs) as well as the serializer based on the HTTP1.1 feature of chunked
Transfer-Encoding
.The scaffold generates
TypedDicts
with the event member of typeIterator[<MemberShape>]
.The serializer in turn serializes these events such that a generator is returned in the serialized
Response
.This allows fully-typed service implementations for the streaming responses where all the encoding is done transparently in the serializer. Here's a dummy implementation of Kinesis' SubscribeToShard operation using the features introduced in this PR:
The support is a bit rudimentary for now, since in current implementations we only use the very basic "happy path" for the event streams. Therefore the error serialization is not yet fully implemented.
This PR is a prerequisite for the upcoming ASF migration of Kinesis (/cc @baermat) as well as of S3.