rate_limiter/
rate_limiter.rs1use amazon_spapi::client::rate_limiter;
2use anyhow::Result;
3
4#[tokio::main]
5async fn main() -> Result<()> {
6 let rate_limiter = rate_limiter::RateLimiter::new(); {
8 let _ = rate_limiter.wait("func1", 0.5, 1).await?;
9 println!("Function 1 executed once");
10 }
11 {
12 let _ = rate_limiter.wait("func1", 0.5, 1).await?;
13 println!("Function 1 executed twice");
14 }
15 {
16 let _ = rate_limiter.wait("func1", 0.5, 1).await?;
17 println!("Function 1 executed thrice");
18 }
19 {
20 let _ = rate_limiter.wait("func1", 0.5, 1).await?;
21 println!("Function 1 executed four times");
22 }
23
24 Ok(())
25}