tuwunel_admin/query/peer_status/
should_attempt.rs1use ruma::OwnedServerName;
2use tokio::time::Instant;
3use tuwunel_core::{Result, utils::time};
4use tuwunel_service::federation::ShouldAttempt;
5
6use crate::admin_command;
7
8#[admin_command]
9pub(super) async fn peer_status_should_attempt(&self, server_name: OwnedServerName) -> Result {
10 let timer = Instant::now();
11 let verdict = self
12 .services
13 .federation
14 .should_attempt(&server_name)
15 .await;
16
17 let query_time = timer.elapsed();
18
19 let line = match verdict {
20 | ShouldAttempt::Yes => "Yes; the sender would dispatch immediately.".to_owned(),
21 | ShouldAttempt::Deprioritize =>
22 "Deprioritize; eligible but should sort to the back of any candidate list.".to_owned(),
23 | ShouldAttempt::No { earliest_retry } => {
24 let at = time::format(earliest_retry, "%+");
25 format!("No; earliest retry at {at}.")
26 },
27 };
28
29 write!(self, "{server_name}: {line}\n\nResolved in {query_time:?}.").await
30}