pub struct RateLimitConfig {
pub rpm: u64,
pub tpm: u64,
pub burst_rpm: u64,
pub burst_tpm: u64,
}Expand description
Configuration for the limiter. Zero means “disabled” for that bucket.
Fields§
§rpm: u64§tpm: u64§burst_rpm: u64§burst_tpm: u64Implementations§
Source§impl RateLimitConfig
impl RateLimitConfig
Sourcepub fn from_env() -> Result<Self, String>
pub fn from_env() -> Result<Self, String>
§Errors
When any ATLAS_RATE_LIMIT_* variable is set to something that is not
a whole number. That used to fall through to the default, and the
default here is 0 — the limit is off. An operator who typed
ATLAS_RATE_LIMIT_RPM=1oo got an unlimited server that started
cleanly and said nothing.
Sourcepub fn from_raw(
rpm: Option<&str>,
tpm: Option<&str>,
burst_rpm: Option<&str>,
burst_tpm: Option<&str>,
) -> Result<Self, String>
pub fn from_raw( rpm: Option<&str>, tpm: Option<&str>, burst_rpm: Option<&str>, burst_tpm: Option<&str>, ) -> Result<Self, String>
The decision, without the environment.
Split out so the refusals are testable: set_var is process-global and
would race every other test in this binary, so the environment is read
by Self::from_env and judged here.
§Errors
As Self::from_env.
pub fn is_enabled(&self) -> bool
Trait Implementations§
Source§impl Clone for RateLimitConfig
impl Clone for RateLimitConfig
Source§fn clone(&self) -> RateLimitConfig
fn clone(&self) -> RateLimitConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RateLimitConfig
impl Debug for RateLimitConfig
impl Copy for RateLimitConfig
Auto Trait Implementations§
impl Freeze for RateLimitConfig
impl RefUnwindSafe for RateLimitConfig
impl Send for RateLimitConfig
impl Sync for RateLimitConfig
impl Unpin 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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