mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
reduce duplicate events
I hate `log_error`. A better way to do this would be to not reuse the same error type literally everywhere, so you could distinguish, in `crate::service::sending::Service::handle_response`, whether to emit an event based on which function created the error. Fixing that is a lot more work, though.
This commit is contained in:
parent
82cc605b5f
commit
e83a30af4b
2 changed files with 12 additions and 8 deletions
|
|
@ -130,10 +130,11 @@ impl FedDest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(request), fields(url))]
|
#[tracing::instrument(skip(request, log_error), fields(url))]
|
||||||
pub(crate) async fn send_request<T>(
|
pub(crate) async fn send_request<T>(
|
||||||
destination: &ServerName,
|
destination: &ServerName,
|
||||||
request: T,
|
request: T,
|
||||||
|
log_error: bool,
|
||||||
) -> Result<T::IncomingResponse>
|
) -> Result<T::IncomingResponse>
|
||||||
where
|
where
|
||||||
T: OutgoingRequest + Debug,
|
T: OutgoingRequest + Debug,
|
||||||
|
|
@ -330,10 +331,12 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
if log_error {
|
||||||
warn!(
|
warn!(
|
||||||
error = %e,
|
error = %e,
|
||||||
"Could not send request",
|
"Could not send request",
|
||||||
);
|
);
|
||||||
|
}
|
||||||
Err(e.into())
|
Err(e.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -286,8 +286,8 @@ impl Service {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_err) => {
|
Err(error) => {
|
||||||
warn!("Marking transaction as failed");
|
warn!(%error, "Marking transaction as failed");
|
||||||
current_transaction_status.entry(destination).and_modify(|e| {
|
current_transaction_status.entry(destination).and_modify(|e| {
|
||||||
*e = match e {
|
*e = match e {
|
||||||
TransactionStatus::Running => {
|
TransactionStatus::Running => {
|
||||||
|
|
@ -684,7 +684,7 @@ impl Service {
|
||||||
debug!("Got permit");
|
debug!("Got permit");
|
||||||
let response = tokio::time::timeout(
|
let response = tokio::time::timeout(
|
||||||
Duration::from_secs(2 * 60),
|
Duration::from_secs(2 * 60),
|
||||||
server_server::send_request(destination, request),
|
server_server::send_request(destination, request, true),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| {
|
.map_err(|_| {
|
||||||
|
|
@ -920,6 +920,7 @@ async fn handle_federation_event(
|
||||||
))
|
))
|
||||||
.into(),
|
.into(),
|
||||||
},
|
},
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue