use std::time::Duration;
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub enum ThrottleStrategy {
#[default]
Delay,
Reject,
Drop,
}
#[derive(Debug, Clone)]
pub struct ThrottlerConfig {
pub max_requests: usize,
pub period: Duration,
pub strategy: ThrottleStrategy,
}
impl ThrottlerConfig {
pub fn new(max_requests: usize, period: Duration) -> Self {
Self {
max_requests,
period,
strategy: ThrottleStrategy::default(),
}
}
pub fn strategy(mut self, s: ThrottleStrategy) -> Self {
self.strategy = s;
self
}
}