pub struct Manager { /* private fields */ }
Expand description
Data used to limit requests.
One instance of this is used per Listener
.
It counts using a atomic::AtomicUsize
and keeps the count of requests per
IpAddr
in a Mutex
, for fast access times and cheap cloning.
Implementations§
source§impl LimitManager
impl LimitManager
sourcepub fn new(max_requests: usize, check_every: usize, reset_seconds: f64) -> Self
pub fn new(max_requests: usize, check_every: usize, reset_seconds: f64) -> Self
Creates a new manager.
Use LimitManager::default
for sane defaults.
The number of allowed requests per reset is max_requests * check_every
.
After reset_seconds
, all data is cleared.
As the math implies, increasing max_requests
and lowering reset_seconds
does nothing to the amount of accepted requests.
Though, if you have large reset_seconds
, it’ll take longer
for the limits to clear after the user