Unify more of the p2/p3 paths in the wasmtime-wasi-http crate#13812
Open
alexcrichton wants to merge 6 commits into
Open
Unify more of the p2/p3 paths in the wasmtime-wasi-http crate#13812alexcrichton wants to merge 6 commits into
alexcrichton wants to merge 6 commits into
Conversation
This commit is made in preparation for eventually merging the `WasiHttpHooks` traits of the p2 and p3 modules to ensure that they're handled uniformly across the crate. This'll pave the way for future refactoring such as only handling one `default_send_request` and more uniform handling of HTTP headers. These traits are not merged yet, however, and the goal of this commit is to resolve a major point of divergence: the `send_request` method. This commit changes the wasip2 signature to instead look like the wasip3 signature. One change made in this commit as a result is that the between-bytes-timeout is now only handled by default in `default_send_request` instead of unconditionally wrapping whatever the host generated. This is in-line with what wasip3 does, for example. Much of this commit is juggling types around to get things to line up, so various signatures/etc were all refactored along the way.
This commit starts paving the path to having wasip2 and wasip3 for HTTP use the same context, hook trait, etc. The main piece introduced here is a new `wasmtime_wasi_http::Error` type which is intended to unify the wasip2 and wasip3 error codes while also supporting other typed errors. This does not yet update wasip2 and only updates the wasip3 side of things. Much of the wasip3 changes are juggling errors types where everything coming from the host is an `Error` while everything related to the guest is an `ErrorCode`. Locations were adjusted as appropriate to convert where needed.
Also get all the tests passing
No need for so much error conversion now that there's one crate type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 takes us further down the road of designing the wasmtime-wasi-http crate in the same manner as the wasmtime-wasi crate which is to say that there's one source-of-truth context/configuration/etc which all WASI impls are derived from. Previously there were separate hooks/contexts for p2/p3 due to historical differences, and this is a refactoring to bring the two together.
The largest part of the refactoring here is the addition of a new
wasmtime_wasi_http::Errortype which unifies p2/p3 as well as underlying possible errors. This means that host-facing operations now work with this type rather than the raw WIT types.Some pieces this helps are:
default_send_requesthandler.rsmoduleNote that this is currently built on #13810