Skip to main content

Module peer

Module peer 

Source
Expand description

Stores and evaluates per-server federation reachability.

Each failure is a blind write keyed by (server, bucket), with repeated failures in one window deliberately coalescing; current row values retain the classification and exact failure time. A scan derives the latest anchor and surviving bucket span before applying the retry curve. Successful outbound or inbound contact clears the server prefix. The bucket width comes from sending.timeout, keeping this gate aligned with sender backoff.

Re-exportsΒ§

use std::collections::BTreeMap; πŸ”’
use std::time::Duration; πŸ”’
use std::time::SystemTime; πŸ”’
use std::time::UNIX_EPOCH; πŸ”’
use futures::Stream; πŸ”’
use futures::StreamExt; πŸ”’
use http::StatusCode; πŸ”’
use ruma::OwnedServerName; πŸ”’
use ruma::ServerName; πŸ”’
use ruma::api::error::ErrorBody; πŸ”’
use tuwunel_core::Error; πŸ”’
use tuwunel_core::implement; πŸ”’
use tuwunel_core::utils::stream::ReadyExt; πŸ”’
use tuwunel_core::utils::stream::TryIgnore; πŸ”’
use tuwunel_core::utils::time::now_secs; πŸ”’
use tuwunel_database::Interfix; πŸ”’

StructsΒ§

Backoff πŸ”’
Latest-failure state feeding the pure attempt_verdict decision.
PeerBackoff
Summarizes a peer’s current failure streak for administration.
Streak πŸ”’
Fold state accumulated over one server’s failure rows.

EnumsΒ§

Classification
Permanence classification supplied alongside a failure.
ShouldAttempt
Verdict returned by super::Service::should_attempt.

ConstantsΒ§

MAX_BACKOFF πŸ”’
Caps peer-status backoff delays.

FunctionsΒ§

attempt_verdict πŸ”’
Computes a retry verdict from a peer’s latest failure state.
classify πŸ”’
Decodes the classification byte from a peer-status value.
classify_error πŸ”’
Classifies a failed federation attempt for the peer-reachability store.
failure_secs πŸ”’
Decodes the recorded failure instant in seconds since the epoch.
fold_streak πŸ”’
Folds one failure row into a server’s running streak.
is_content_rejection
Whether a failed federation attempt is a content rejection from a reachable peer, the one failure of a sent request the peer-reachability store does not record.