congestion_limiter/limits/fixed.rs
1use async_trait::async_trait;
2
3use super::{LimitAlgorithm, Sample};
4
5/// A simple, fixed concurrency limit.
6#[derive(Debug)]
7pub struct Fixed(usize);
8impl Fixed {
9 #[allow(missing_docs)]
10 pub fn new(limit: usize) -> Self {
11 assert!(limit > 0);
12
13 Self(limit)
14 }
15}
16
17#[async_trait]
18impl LimitAlgorithm for Fixed {
19 fn limit(&self) -> usize {
20 self.0
21 }
22
23 async fn update(&self, _reading: Sample) -> usize {
24 self.0
25 }
26}