rusty_rl/lib.rs
1use std::{
2 collections::HashMap,
3 time::{Duration, Instant},
4};
5// mod bucket;
6mod fixed;
7// mod fixed_bucket;
8
9///
10///
11
12/// fixed bucket
13///
14/// ```
15/// let b = FixedBucket::new(600, 10).bucket(90, 10.0)
16/// ```
17///
18/// ```
19/// b.allow(unique value) // boolean
20/// ```
21
22pub struct FixedLimit {
23 maximum_request: usize,
24 duration: Duration,
25 requests: HashMap<String, (usize, Instant)>,
26}
27
28pub struct Selfb {
29 pub remaning_count: u64,
30 pub is_allowed: bool,
31 pub route: String,
32}
33
34// pub struct TokenBucket {
35// capacity: u64,
36// rates: f64,
37// last_update: HashMap<String, (f64, Instant)>,
38// }
39
40// pub struct FixedBucket {
41// request: u64,
42// duration: Duration,
43// capacity: u64,
44// rates: f64,
45// last_update: HashMap<String, (f64, Instant)>,
46// requests: HashMap<String, (u64, Instant)>,
47// }