Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rate limit 10 req/min #331

Merged
merged 2 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't rename to PER_MIN and removed instead since the desire to change rate limit is more than just changing this constant; we may change the window too


#[derive(Clone)]
pub struct RateLimiter {
cache: Arc<Cache<IpAddr, u32>>,
Expand Down
4 changes: 2 additions & 2 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ pub fn new_state(
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),
10,
Duration::from_secs(60),
),
})
}
Expand Down
Loading