-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
add test/example for outbound request body streaming #1991
Conversation
// won't necessarily have a chance to send the request body if they haven't started doing so yet (or, if they | ||
// have started, they might not be able to finish before the connection is closed). See | ||
// https://github.com/bytecodealliance/wasmtime/issues/7413 for details. | ||
pub fn take_body_stream(&self) -> impl futures::Stream<Item = Result<Vec<u8>, streams::Error>> { |
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.
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.
Yes and yes. The API change is necessary because there's no other way to work around bytecodealliance/wasmtime#7413, and I'm not sure when that will be fixed or whether it will be backported to Wasmtime 14 (and if it is, probably not in time for Spin 2.0).
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.
Update: here's a PR with the fix: bytecodealliance/wasmtime#7426
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. I think we'll want to revisit the streaming API in the future to see if we can make things less error prone, but given the current state of the world these changes look great.
@@ -461,14 +461,24 @@ impl IncomingResponse { | |||
/// # Panics | |||
/// | |||
/// Panics if the body was already consumed. | |||
pub fn into_body_stream(self) -> impl futures::Stream<Item = Result<Vec<u8>, streams::Error>> { | |||
// TODO: This should ideally take ownership of `self` and be called `into_body_stream` (i.e. symmetric with |
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.
Sigh... I think this whole API might need another look - it's hard to get the flow right. Oh well...
0219a5d
to
bd7f08e
Compare
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
This also removes some documentation from `spin_sdk::http::send` which turned out to be incorrect; you _can_ safely await the returned future prior to dropping the body handle. Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Turns out there's no need to delay `await`ing the future returned from `executor::outgoing_request_send`. Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
bd7f08e
to
891493a
Compare
No description provided.