-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Send between threads error when using actix_web client with juniper #1351
Comments
Hello @arlyon , You may need reqwest. By default actix-web starts mutiple workers and every worker owns its proper data. So basically, it's designed like this. |
Seems like its the error handling that's at fault here? Does it compile if you use .unwrap instead of ? on the .send().await line? |
@robjtede Converting all the out.log
|
So, any ideas on that? I could try to use Considering HTTP overhead overall I think there is no much problem in atomic increment overhead. It won't be significant comparing to network issues. |
As said above I really don't get it.
Because I'd like to register it as
Why design is this? Could you show some benefits of doing it this way?The current issue in a nutshell: let something_with_client = Something::new(&env_config.url);
let server = HttpServer::new(move || {
let something_with_client = something_with_client .clone();
...
...
error[E0277]: `Rc<awc::ClientConfig>` cannot be sent between threads safely
--> src\server.rs:47:18
|
47 | let server = HttpServer::new(move || {
| __________________^^^^^^^^^^^^^^^_-
| | |
| | `Rc<awc::ClientConfig>` cannot be sent between threads safely
... |
144 | | ))
145 | | })
| |_____- within this `[closure@src\server.rs:47:34: 145:6]`
|
= help: within `[closure@src\server.rs:47:34: 145:6]`, the trait `std::marker::Send` is not implemented for `Rc<awc::ClientConfig>`
= note: required because it appears within the type `actix_web::client::Client`
= note: required because it appears within the type `AuthClient`
= note: required because it appears within the type `[closure@src\server.rs:47:34: 145:6]`
= note: required by `HttpServer::<F, I, S, B>::new` I'm forced to move creating code somewhere else and create new client for each actor although one shared instance would be just fine. |
I think what @Pzixel was looking for is something like this: https://github.com/actix/examples/blob/master/http-proxy/src/main.rs#L139-L144 Both Just leaving this note for anyone (like me) who arrives here searching for an answer to this. |
Describe the bug
When trying to use the actix_web client inside an impl decorated with
graphql_object
, a number of errors pop up regarding sending futures between threads. I have posted an issue on juniper graphql-rust/juniper#529 but figured this needed visibility on both ends.This is on juniper master with the async feature enabled.
out.log
To Reproduce
I created a minimum reproducing repository here, based on the actix web example: https://github.com/arlyon/examples/tree/juniper-actix-error/juniper
Expected behavior
I would expect this to work correctly. It should be noted that hyper works fine, but I'd like to avoid using another client when I have one baked in.
The text was updated successfully, but these errors were encountered: