pub struct RateLimitConfig {
pub per_peer_rate_per_sec: f64,
pub per_peer_burst: u32,
pub per_ip_rate_per_sec: f64,
pub per_ip_burst: u32,
pub global_rate_per_sec: f64,
pub global_burst: u32,
pub max_tracked_per_ip: usize,
pub max_tracked_per_peer: usize,
}Expand description
Resolved three-layer rate-limit configuration.
A layer is disabled (its Option<_> limiter is None) when its quota is
not buildable — see make_quota: that is *_rate_per_sec <= 0.0, a
non-finite rate, or *_burst == 0. The intended operator opt-out sets
both the rate to 0.0 and the burst to 0; the config resolver
(resolve_{dht,probe}_into) rejects the asymmetric rate > 0, burst == 0
combination up front, so in production a layer is only ever disabled via the
both-zero opt-out. A RateLimitConfig built directly (bypassing the
resolver) with rate > 0, burst == 0 will silently disable that layer
rather than error — construct via the From<&Resolved{Dht,Probe}> impls or
the resolver to keep that invariant.
Default returns the ADR 022 DHT-layer values (the historical default of
this struct). The probe path supplies its own ADR 005 defaults through the
config resolver and never relies on Default here.
Fields§
§per_peer_rate_per_sec: f64Per-peer (source NodeId) sustained rate (requests/second).
per_peer_burst: u32Per-peer burst capacity.
per_ip_rate_per_sec: f64Per-IP sustained rate (requests/second).
per_ip_burst: u32Per-IP burst capacity.
global_rate_per_sec: f64Global inbound sustained rate (requests/second).
global_burst: u32Global inbound burst capacity.
max_tracked_per_ip: usizeHard cap on the per-IP keyed-limiter map (#645). 0 => unbounded
(operator opt-in, the resolver warns).
max_tracked_per_peer: usizeHard cap on the per-peer keyed-limiter map (#645). 0 => unbounded.
Trait Implementations§
Source§impl Clone for RateLimitConfig
impl Clone for RateLimitConfig
Source§impl Debug for RateLimitConfig
impl Debug for RateLimitConfig
Source§impl Default for RateLimitConfig
impl Default for RateLimitConfig
Source§impl From<&ResolvedDht> for RateLimitConfig
impl From<&ResolvedDht> for RateLimitConfig
Source§fn from(r: &ResolvedDht) -> Self
fn from(r: &ResolvedDht) -> Self
Source§impl From<&ResolvedProbe> for RateLimitConfig
impl From<&ResolvedProbe> for RateLimitConfig
Source§fn from(r: &ResolvedProbe) -> Self
fn from(r: &ResolvedProbe) -> Self
Auto Trait Implementations§
impl Freeze for RateLimitConfig
impl RefUnwindSafe for RateLimitConfig
impl Send for RateLimitConfig
impl Sync for RateLimitConfig
impl Unpin for RateLimitConfig
impl UnsafeUnpin for RateLimitConfig
impl UnwindSafe for RateLimitConfig
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,
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