pub struct ProbeRateLimiter(/* private fields */);Expand description
Three-layer rate limiter for inbound cdn/probe/v1 requests. Newtype over
the shared ThreeLayerRateLimiter that injects the probe metrics sink.
Implementations§
Source§impl ProbeRateLimiter
impl ProbeRateLimiter
Sourcepub fn new(cfg: &ProbeRateLimitConfig, metrics: Arc<Metrics>) -> Self
pub fn new(cfg: &ProbeRateLimitConfig, metrics: Arc<Metrics>) -> Self
Build a limiter from the resolved probe config snapshot.
Sourcepub fn from_resolved(resolved: &ResolvedProbe, metrics: Arc<Metrics>) -> Self
pub fn from_resolved(resolved: &ResolvedProbe, metrics: Arc<Metrics>) -> Self
Build a limiter straight from the resolved [probe.rate_limit] section.
Prefer this over Self::new at wiring sites. ProbeRateLimitConfig
is an alias of the shared RateLimitConfig, so new accepts a config
mapped from either protocol’s resolved section — building the probe
limiter from [dht.rate_limit] type-checks fine and would quietly
quadruple the per-peer probe cap (ADR 022’s 20/sec in place of ADR 005’s
5/sec). Taking &ResolvedProbe makes that a type error instead (#1457).
Sourcepub fn check(
&self,
peer_node_id: &NodeId,
peer_ip: Option<IpAddr>,
) -> Result<(), ProbeRejectLayer>
pub fn check( &self, peer_node_id: &NodeId, peer_ip: Option<IpAddr>, ) -> Result<(), ProbeRejectLayer>
Try to admit one inbound probe. See ThreeLayerRateLimiter::check.
Sourcepub fn gc_per_ip(&self) -> Option<(usize, usize)>
pub fn gc_per_ip(&self) -> Option<(usize, usize)>
Periodic GC sweep for the per-IP keyed map (#645).
Sourcepub fn gc_per_peer(&self) -> Option<(usize, usize)>
pub fn gc_per_peer(&self) -> Option<(usize, usize)>
Periodic GC sweep for the per-peer keyed map (#645).
Sourcepub fn per_ip_tracked(&self) -> usize
pub fn per_ip_tracked(&self) -> usize
Current tracked-key count for the per-IP keyed map (#645).
Sourcepub fn per_peer_tracked(&self) -> usize
pub fn per_peer_tracked(&self) -> usize
Current tracked-key count for the per-peer keyed map (#645).
Auto Trait Implementations§
impl !Freeze for ProbeRateLimiter
impl !RefUnwindSafe for ProbeRateLimiter
impl !UnwindSafe for ProbeRateLimiter
impl Send for ProbeRateLimiter
impl Sync for ProbeRateLimiter
impl Unpin for ProbeRateLimiter
impl UnsafeUnpin for ProbeRateLimiter
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request