-
Notifications
You must be signed in to change notification settings - Fork 347
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
Refactor Lambda response streaming. #696
Conversation
Remove the separate streaming.rs from lambda-runtime crate. Merge into the `run` method. Added FunctionResponse enum to capture both buffered response and streaming response. Added IntoFunctionResponse trait to convert `Serialize` response into FunctionResponse::BufferedResponse, and convert `Stream` response into FunctionResponse::StreamingResponse. Existing handler functions should continue to work. Improved error handling in response streaming. Return trailers to report errors instead of panic.
|
||
req_headers.insert("Transfer-Encoding", "chunked".parse()?); | ||
req_headers.insert("Lambda-Runtime-Function-Response-Mode", "streaming".parse()?); | ||
req_headers.append("Trailer", "Lambda-Runtime-Function-Error-Type".parse()?); |
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.
can you leave a comment explaining what these Trailer
headers are for?
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.
Done
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.
great, thanks!
This looks good at first glance. I'm going to run some tests today before merging 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.
Looks good. Awesome refactor @bnusunny !
Remove the separate streaming.rs from lambda-runtime crate. Merge into the
run
method.Added FunctionResponse enum to capture both buffered response and streaming response.
Added IntoFunctionResponse trait to convert
Serialize
response into FunctionResponse::BufferedResponse, and convertStream
response into FunctionResponse::StreamingResponse. Existing handler functions should continue to work.Improved error handling in response streaming. Return trailers to report errors instead of panic.
By submitting this pull request