Skip to content

Commit

Permalink
build: Update itertools to 0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-auer committed Sep 5, 2024
1 parent 9c5f180 commit 6c87253
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
29 changes: 19 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ hyper-util = { version = "0.1.7", features = ["tokio"] }
indexmap = "2.2.5"
insta = { version = "1.31.0", features = ["json", "redactions", "ron"] }
ipnetwork = "0.20.0"
itertools = "0.10.5"
itertools = "0.13.0"
json-forensics = "0.1.1"
lru = "0.9.0"
maxminddb = "0.23.0"
Expand Down
12 changes: 7 additions & 5 deletions relay-quotas/src/global.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::sync::{Mutex, OnceLock, PoisonError};

use crate::RedisQuota;
use itertools::Itertools;
use relay_base_schema::metrics::MetricNamespace;
use relay_redis::redis::Script;
use relay_redis::{PooledClient, RedisError};

use crate::RedisQuota;

/// Default percentage of the quota limit to reserve from Redis as a local cache.
const DEFAULT_BUDGET_RATIO: f32 = 0.001;

Expand Down Expand Up @@ -37,11 +38,12 @@ impl GlobalRateLimits {
let mut ratelimited = vec![];
let mut not_ratelimited = vec![];

for (key, quotas) in &quotas.iter().group_by(|quota| KeyRef::new(quota)) {
let Some(quota) = quotas.min_by_key(|quota| quota.limit()) else {
continue;
};
let min_by_keyref = quotas
.iter()
.into_grouping_map_by(|q| KeyRef::new(q))
.min_by_key(|_, q| q.limit());

for (key, quota) in min_by_keyref {
let val = guard.entry_ref(&key).or_default();

if val.is_rate_limited(client, quota, key, quantity as u64)? {
Expand Down

0 comments on commit 6c87253

Please sign in to comment.