-
Notifications
You must be signed in to change notification settings - Fork 252
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
Leverage the tower
ecosystem for http requests
#934
Comments
Hello, We have discussed about your proposal in our weekly meeting. We think it could be a good idea to move to Tower as it won't add too much dependencies and weight to the project, in comparison to the features it can provide. The main 2 features we see is supporting timeouts and retries. Sadly, we don't presently have the bandwidth to implement that though. Would you be willing to open a PR to update the project? We suspect you've a good knowledge of the |
Sure, I'll work on that when I have the time and open a PR |
Thank you! Feel free ping to me anytime. |
This is currently blocked because reqwest's |
Maybe it's just time to find another way to do requests on wasm then. reqwest has always been pretty incomplete in annoying ways on wasm. |
What do you have in mind? Create our own abstraction around the Fetch API (maybe using gloo-net)? Find another library that has better support on all platforms? |
|
I'm not surprised, the built-in tower We'll probably need to implement our own |
Well maybe |
Actually it seems like there's been work on support for WASI in tokio that should be in the next release and in this follow-up issue there's a " We should figure out if it also improved support for the |
If we need WASI support, we can compile Wasmer to WebAssembly, to then execute Wasm modules with Wasmer in a browser for example. It works pretty well. But it's possibly overkill for what we need. For what I know, WASI has no official support for networking API yet (👀 I would suggest to just have another strategy for Wasm for now. This topic is going to be long to converge to a single solution. |
I don't think we are going to move this forward for the moment :-). Let's close it. |
From @sandhose in the Matrix room (permalink):
I've been discussing with @zecakeh for the OIDC client implementation in the Rust SDK, and reusing some of the work I've done in
matrix-authentication-service
. In MAS, I'm leveraging thetower
ecosystem when I'm doing http requests. Instead of using a high-level client likereqwest
, I'm using atower::Service<http::Request, Response = http::Response>
.This allows me to have things like injecting headers, tracing, retries, timeouts, etc. implemented via tower layers. It's pretty powerful IMO, so I wondered if it would make sense to have the same approach in the Rust SDK.
I see that in the Rust SDK, you defined an
HttpSend
trait, which has anasync fn send_request(&self, request: http::Request<Bytes>, config: RequestConfig) -> Result<http::Response<Bytes>, HttpError>
, which is pretty close of what antower::Service<http::Request<Bytes>, Response = http::Response<Bytes>, Error = HttpError>
would provide. What would you think of switching to that instead of theHttpSend
crate? That would help leverage many great things from the tower ecosystemThe text was updated successfully, but these errors were encountered: