-
Notifications
You must be signed in to change notification settings - Fork 361
Generic Buffered/Streaming Response Type Constraints #995
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
Comments
I think I've narrowed it down: it's Am I correct in this reading of it? I'm not sure how to write a |
@naftulikay take a look at this file. It is for streaming a HTTP response. |
@bnusunny okay, taking a look, I'll try to see if I can do something similar and still be able to generically return either a fully buffered response or a streaming response. |
@bnusunny with a little bit of hammering, I was able to get the following working:
|
This issue is now closed. Comments on closed issues are hard for our team to see. |
I'm writing a fairly generic all-in-one Lambda function which will be handling many different types of events. For example, SQS, SNS, CloudWatch scheduled events, S3 events, SES events, and of course API Gateway requests/responses. I have an existing Rust Lambda doing this but it's incredibly old (from the
crowbar
days) so I'm essentially rewriting it from scratch.I'm implementing
tower::Service
for my service directly and I'm trying to define its outputs so that I can return either a synchronous buffered response or a streaming response so I can have the flexibility of both. I'm aware that the only case that streaming is applicable is in API Gateway responses.My main function simply instantiates the service and calls
lambda_runtime::run
with it:When I try to compile this:
Note my type alias definition for the response:
I've tried a number of different values for
StreamResponse<S>
:lambda_runtime::streaming::Body
axum::body::Body
axum::body::BodyDataStream
All of these fail indicating:
The issue is that it appears that for all of the above types,
Stream
is implemented, so I'm a bit confused as to why this is happening.I'm happy to contribute an example showing a generic return over both outcomes if I can get some help wrangling the types.
The text was updated successfully, but these errors were encountered: