use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RateLimiterConfig {
pub requests_per_second: u64,
pub burst_capacity: u64,
pub adaptive: bool,
pub initial_rate: Option<u64>,
}
impl Default for RateLimiterConfig {
fn default() -> Self {
Self {
requests_per_second: 10,
burst_capacity: 20,
adaptive: false,
initial_rate: None,
}
}
}
impl RateLimiterConfig {
pub fn production() -> Self {
Self {
requests_per_second: 5,
burst_capacity: 10,
adaptive: true,
initial_rate: Some(5),
}
}
pub fn development() -> Self {
Self {
requests_per_second: 20,
burst_capacity: 50,
adaptive: false,
initial_rate: None,
}
}
pub fn conservative() -> Self {
Self {
requests_per_second: 2,
burst_capacity: 5,
adaptive: true,
initial_rate: Some(1),
}
}
}