pub struct RelayClient { /* private fields */ }Expand description
A thin, read-only client over the public relays.
Holds the shared reqwest::Client (never builds its own — one connection
pool for the whole 512 MB box) and the normalized host list. Every request
goes through crate::net::guarded_get_no_privacy; see the module doc for
why.
Implementations§
Source§impl RelayClient
impl RelayClient
Sourcepub fn new(http: Client, hosts: &[String]) -> Result<Self, RelayError>
pub fn new(http: Client, hosts: &[String]) -> Result<Self, RelayError>
Build a client over hosts (bare hostnames or full URLs; see
normalize_relay_host), deduped with configured order preserved.
An empty host list is Ok and yields is_enabled() == false — that
is the operator’s second off-switch, alongside an interval of 0, and
must not be an error. A malformed host, by contrast, fails loud: a typo
should be visible, not silently probed forever.
Sourcepub fn with_page_limit(self, limit: u32) -> Self
pub fn with_page_limit(self, limit: u32) -> Self
Override the per-page repo limit, clamped into the relay’s usable range.
The seam a future config knob would use; the clamp is what stops a 0
(which the live relay answers with one repo and a cursor) from burning
the whole page budget.
Sourcepub fn hosts(&self) -> &[String]
pub fn hosts(&self) -> &[String]
The normalized relay base URLs this client will query, in order.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Whether there is anything to query at all.
Sourcepub async fn count_repos_with_collection(
&self,
collection: &str,
) -> AdoptionReport
pub async fn count_repos_with_collection( &self, collection: &str, ) -> AdoptionReport
Count the repos holding collection on every configured relay.
Hosts are queried sequentially, in configured order: the politeness
budget is per-run, both default relays are operated by the same party,
and sequential keeps peak memory at one page while making observations
deterministically ordered. A 429 from any host aborts the whole run
(both defaults sit behind one operator’s rate limiter, so hammering the
next one after the first says “slow down” is the impolite reading).
Never returns Err: a failure is data, recorded per-host on the report.
Trait Implementations§
Source§impl Clone for RelayClient
impl Clone for RelayClient
Source§fn clone(&self) -> RelayClient
fn clone(&self) -> RelayClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for RelayClient
impl !UnwindSafe for RelayClient
impl Freeze for RelayClient
impl Send for RelayClient
impl Sync for RelayClient
impl Unpin for RelayClient
impl UnsafeUnpin for RelayClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more