How to share reqwest::Client in all async calls on a thread created by HttpServer of actix web #2237
-
In : actix_web 4.0.0-beta6 I have 8 logical cores, so i suppose HttpServer will spin 8 workers(threads). So, what i wanna do is create a reqwest::Client (from reqwest crate)(Http client) and make an HTTP request to a service created using "Deno" Currently im creating a new reqwest::Client on on each request made on this (actix-web)server. I found that sharing reqwest::Client among all these 8 threads is not possible (till now i haven't been able to). So i want reqwest::Client to be created on the creation of each of these threads created by HttpServer. So 8 actix workers have their own reqwest::Client object and this way i do not have to create a new reqwest::Client object on every user request. So, i want to create only one reqwest::Client object for each thread and use that object to make http request when my actix-web app makes an HTTP request from one of these threads. Is there any way to do so.............help!!! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
https://github.com/actix/examples/tree/master/basics/state