Skip to content

Commit 462dc2b

Browse files
committed
rename fast-fail to fail-fast and remove downvoting for offline destinations
1 parent de6ff21 commit 462dc2b

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/relay/api.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ async fn federation<D: TwinDB, R: RateLimiter>(
210210

211211
let dst: SessionID = (&envelope.destination).into();
212212

213-
// fast-fail path: if requested and destination is not local, return error immediately
214-
if has_fast_fail(&envelope) && !data.switch.is_local(&dst).await {
213+
// fail-fast path: if requested and destination is not local, return error immediately
214+
if has_fail_fast(&envelope) && !data.switch.is_local(&dst).await {
215215
// destination session doesn’t exist on this relay
216216
return Response::builder()
217217
.status(http::StatusCode::NOT_FOUND)
@@ -232,7 +232,7 @@ async fn federation<D: TwinDB, R: RateLimiter>(
232232
/// Canonical tag is "fail-fast" (kebab-case). Matching is token-based (comma/whitespace
233233
/// separated) and case-sensitive. No legacy aliases are supported.
234234
#[inline]
235-
fn has_fast_fail(envelope: &Envelope) -> bool {
235+
pub(crate) fn has_fail_fast(envelope: &Envelope) -> bool {
236236
const TAG_FAIL_FAST: &str = "fail-fast";
237237

238238
let tags = match envelope.tags.as_deref() {
@@ -452,9 +452,9 @@ impl<M: Metrics, D: TwinDB> Session<M, D> {
452452
// push message to the (relay.federation) queue
453453
return Ok(self.federator.send(&msg).await?);
454454
}
455-
// fast-fail path: we confirmed that this is not an foreign message, and if it is fast-fail taged and destination session is not connected
455+
// fail-fast path: we confirmed that this is not an foreign message, and if it is fail-fast taged and destination session is not connected
456456
// then the peer must be offline, return error immediately
457-
if has_fast_fail(envelope) && !is_local {
457+
if has_fail_fast(envelope) && !is_local {
458458
anyhow::bail!("destination offline");
459459
}
460460
// we don't return an error because when we return an error

src/relay/federation/router.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ where
109109
domain.as_ref(),
110110
resp.status()
111111
);
112-
self.ranker.downvote(domain.as_ref()).await;
113-
return Err(RouterError::Permanent(resp.status().to_string()));
112+
// Do NOT downvote offline
113+
return Err(RouterError::Permanent("destination offline".into()));
114114
}
115115

116116
// For other statuses (e.g., 5xx), downvote and try next candidate

0 commit comments

Comments
 (0)