Skip to content

Commit

Permalink
fix: rate limit 10 req/min (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 committed May 17, 2024
1 parent e4d083b commit 1c3a860
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
2 changes: 0 additions & 2 deletions src/middleware/rate_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use std::{net::IpAddr, sync::Arc};
use tokio::time::Duration;
use tracing::error;

pub const MAX_REQUESTS_PER_SEC: u32 = 10;

#[derive(Clone)]
pub struct RateLimiter {
cache: Arc<Cache<IpAddr, u32>>,
Expand Down
5 changes: 1 addition & 4 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ pub fn new_state(
uptime: std::time::Instant::now(),
http_client: reqwest::Client::new(),
provider_cache: Cache::new(100),
rate_limit: rate_limit::RateLimiter::new(
rate_limit::MAX_REQUESTS_PER_SEC,
Duration::from_secs(1),
),
rate_limit: rate_limit::RateLimiter::new(10, Duration::from_secs(60)),
})
}

Expand Down

0 comments on commit 1c3a860

Please sign in to comment.