fix using same federation reqwest pool after sender deduplication.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-04-04 17:48:12 -07:00 committed by June
parent ca1c77d76b
commit 7f6c19f066
2 changed files with 8 additions and 9 deletions

View file

@ -234,7 +234,8 @@ impl Service {
{
let permit = self.maximum_requests.acquire().await;
let timeout = Duration::from_secs(self.timeout);
let response = tokio::time::timeout(timeout, send::send_request(dest, request))
let client = &services().globals.client.federation;
let response = tokio::time::timeout(timeout, send::send_request(client, dest, request))
.await
.map_err(|_| {
warn!("Timeout after 300 seconds waiting for server response of {dest}");
@ -781,8 +782,9 @@ async fn handle_events_kind_normal(
}
let permit = services().sending.maximum_requests.acquire().await;
let client = &services().globals.client.sender;
let response = send::send_request(
client,
dest,
send_transaction_message::v1::Request {
origin: services().globals.server_name().to_owned(),

View file

@ -44,7 +44,9 @@ pub enum FedDest {
}
#[tracing::instrument(skip_all, name = "send")]
pub(crate) async fn send_request<T>(destination: &ServerName, request: T) -> Result<T::IncomingResponse>
pub(crate) async fn send_request<T>(
client: &reqwest::Client, destination: &ServerName, request: T,
) -> Result<T::IncomingResponse>
where
T: OutgoingRequest + Debug,
{
@ -202,12 +204,7 @@ where
}
debug!("Sending request to {destination} at {url}");
let response = services()
.globals
.client
.federation
.execute(reqwest_request)
.await;
let response = client.execute(reqwest_request).await;
debug!("Received response from {destination} at {url}");
match response {