pub struct RateLimitConfig {
pub default_limit: usize,
pub api_limits: HashMap<String, usize>,
}Expand description
Configuration for per-API concurrency limiting.
Provides the building blocks for concurrency control. Provider crates supply their own defaults (e.g. GCP API quotas).
§Example
use cloud_lite_core::rate_limit::RateLimitConfig;
let config = RateLimitConfig::new(20)
.with_api_limit("api.example.com", 10);
let disabled = RateLimitConfig::disabled();Fields§
§default_limit: usizeConcurrency limit for APIs not in api_limits.
api_limits: HashMap<String, usize>Per-API concurrency limits keyed by host (e.g. “compute.googleapis.com”).
Implementations§
Source§impl RateLimitConfig
impl RateLimitConfig
Sourcepub fn new(default_limit: usize) -> Self
pub fn new(default_limit: usize) -> Self
Create a new config with the given default concurrency limit.
Sourcepub fn with_default_limit(self, limit: usize) -> Self
pub fn with_default_limit(self, limit: usize) -> Self
Override the default concurrency limit for unknown APIs.
Sourcepub fn with_api_limit(self, host: &str, limit: usize) -> Self
pub fn with_api_limit(self, host: &str, limit: usize) -> Self
Set or override the concurrency limit for a specific API host.
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 moreAuto 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
Mutably borrows from an owned value. Read more