mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2024-12-04 20:08:10 +00:00
add federation client for select high-timeout requests
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
f82eba1861
commit
37b9b361ba
|
@ -769,7 +769,7 @@ async fn join_room_by_id_helper_remote(
|
|||
|
||||
let send_join_response = services
|
||||
.sending
|
||||
.send_federation_request(&remote_server, send_join_request)
|
||||
.send_synapse_request(&remote_server, send_join_request)
|
||||
.await?;
|
||||
|
||||
info!("send_join finished");
|
||||
|
@ -1148,7 +1148,7 @@ async fn join_room_by_id_helper_local(
|
|||
|
||||
let send_join_response = services
|
||||
.sending
|
||||
.send_federation_request(
|
||||
.send_synapse_request(
|
||||
&remote_server,
|
||||
federation::membership::create_join_event::v2::Request {
|
||||
room_id: room_id.to_owned(),
|
||||
|
|
|
@ -1767,7 +1767,7 @@ fn default_well_known_conn_timeout() -> u64 { 6 }
|
|||
|
||||
fn default_well_known_timeout() -> u64 { 10 }
|
||||
|
||||
fn default_federation_timeout() -> u64 { 300 }
|
||||
fn default_federation_timeout() -> u64 { 25 }
|
||||
|
||||
fn default_federation_idle_timeout() -> u64 { 25 }
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ pub struct Service {
|
|||
pub extern_media: reqwest::Client,
|
||||
pub well_known: reqwest::Client,
|
||||
pub federation: reqwest::Client,
|
||||
pub synapse: reqwest::Client,
|
||||
pub sender: reqwest::Client,
|
||||
pub appservice: reqwest::Client,
|
||||
pub pusher: reqwest::Client,
|
||||
|
@ -48,12 +49,18 @@ impl crate::Service for Service {
|
|||
federation: base(config)?
|
||||
.dns_resolver(resolver.resolver.hooked.clone())
|
||||
.read_timeout(Duration::from_secs(config.federation_timeout))
|
||||
.timeout(Duration::from_secs(config.federation_timeout))
|
||||
.pool_max_idle_per_host(config.federation_idle_per_host.into())
|
||||
.pool_idle_timeout(Duration::from_secs(config.federation_idle_timeout))
|
||||
.redirect(redirect::Policy::limited(3))
|
||||
.build()?,
|
||||
|
||||
synapse: base(config)?
|
||||
.dns_resolver(resolver.resolver.hooked.clone())
|
||||
.read_timeout(Duration::from_secs(305))
|
||||
.pool_max_idle_per_host(0)
|
||||
.redirect(redirect::Policy::limited(3))
|
||||
.build()?,
|
||||
|
||||
sender: base(config)?
|
||||
.dns_resolver(resolver.resolver.hooked.clone())
|
||||
.read_timeout(Duration::from_secs(config.sender_timeout))
|
||||
|
|
|
@ -1016,7 +1016,7 @@ impl Service {
|
|||
let res = self
|
||||
.services
|
||||
.sending
|
||||
.send_federation_request(
|
||||
.send_synapse_request(
|
||||
origin,
|
||||
get_room_state_ids::v1::Request {
|
||||
room_id: room_id.to_owned(),
|
||||
|
|
|
@ -245,6 +245,7 @@ impl Service {
|
|||
.await
|
||||
}
|
||||
|
||||
/// Sends a request to a federation server
|
||||
#[tracing::instrument(skip_all, name = "request")]
|
||||
pub async fn send_federation_request<T>(&self, dest: &ServerName, request: T) -> Result<T::IncomingResponse>
|
||||
where
|
||||
|
@ -254,6 +255,16 @@ impl Service {
|
|||
self.send(client, dest, request).await
|
||||
}
|
||||
|
||||
/// Like send_federation_request() but with a very large timeout
|
||||
#[tracing::instrument(skip_all, name = "synapse")]
|
||||
pub async fn send_synapse_request<T>(&self, dest: &ServerName, request: T) -> Result<T::IncomingResponse>
|
||||
where
|
||||
T: OutgoingRequest + Debug + Send,
|
||||
{
|
||||
let client = &self.services.client.synapse;
|
||||
self.send(client, dest, request).await
|
||||
}
|
||||
|
||||
/// Sends a request to an appservice
|
||||
///
|
||||
/// Only returns None if there is no url specified in the appservice
|
||||
|
|
Loading…
Reference in a new issue