From f5fdd30298b32cd85a38e00394f218c05839faa9 Mon Sep 17 00:00:00 2001 From: Alex Snaps Date: Tue, 2 Jul 2024 10:19:44 -0400 Subject: [PATCH 1/2] Edition 2024: See rust lang issue 123748 --- limitador/src/storage/redis/redis_async.rs | 6 +++--- limitador/src/storage/redis/redis_sync.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/limitador/src/storage/redis/redis_async.rs b/limitador/src/storage/redis/redis_async.rs index ac2fdc51..4da003a7 100644 --- a/limitador/src/storage/redis/redis_async.rs +++ b/limitador/src/storage/redis/redis_async.rs @@ -56,7 +56,7 @@ impl AsyncCounterStorage for AsyncRedisStorage { .key(key_for_counters_of_limit(counter.limit())) .arg(counter.window().as_secs()) .arg(delta) - .invoke_async::<_, _>(&mut con) + .invoke_async::<_, ()>(&mut con) .instrument(info_span!("datastore")) .await?; @@ -191,7 +191,7 @@ impl AsyncCounterStorage for AsyncRedisStorage { async fn clear(&self) -> Result<(), StorageErr> { let mut con = self.conn_manager.clone(); redis::cmd("FLUSHDB") - .query_async(&mut con) + .query_async::<_, ()>(&mut con) .instrument(info_span!("datastore")) .await?; Ok(()) @@ -224,7 +224,7 @@ impl AsyncRedisStorage { }; for counter_key in counter_keys { - con.del(counter_key) + con.del::<_, ()>(counter_key) .instrument(info_span!("datastore")) .await?; } diff --git a/limitador/src/storage/redis/redis_sync.rs b/limitador/src/storage/redis/redis_sync.rs index 81eb3f11..52d66fc3 100644 --- a/limitador/src/storage/redis/redis_sync.rs +++ b/limitador/src/storage/redis/redis_sync.rs @@ -49,7 +49,7 @@ impl CounterStorage for RedisStorage { .key(key_for_counters_of_limit(counter.limit())) .arg(counter.window().as_secs()) .arg(delta) - .invoke(&mut *con)?; + .invoke::<()>(&mut *con)?; Ok(()) } @@ -101,7 +101,7 @@ impl CounterStorage for RedisStorage { .key(key_for_counters_of_limit(counter.limit())) .arg(counter.window().as_secs()) .arg(delta) - .invoke(&mut *con)?; + .invoke::<()>(&mut *con)?; } Ok(Authorization::Ok) @@ -154,7 +154,7 @@ impl CounterStorage for RedisStorage { con.smembers::>(key_for_counters_of_limit(limit.deref()))?; for counter_key in counter_keys { - con.del(counter_key)?; + con.del::<_, ()>(counter_key)?; } } From 1e5433ce1ed53ed4fe3e306a787b97051e70dec0 Mon Sep 17 00:00:00 2001 From: Alex Snaps Date: Tue, 2 Jul 2024 10:21:42 -0400 Subject: [PATCH 2/2] rustdocs? --- limitador/src/lib.rs | 6 +++--- limitador/src/storage/redis/redis_cached.rs | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/limitador/src/lib.rs b/limitador/src/lib.rs index a71de204..3606730f 100644 --- a/limitador/src/lib.rs +++ b/limitador/src/lib.rs @@ -36,13 +36,13 @@ //! //! The definition of a limit includes: //! - A namespace that identifies the resource to limit. It could be an API, a -//! Kubernetes service, a proxy ID, etc. +//! Kubernetes service, a proxy ID, etc. //! - A value. //! - The length of the period in seconds. //! - Conditions that define when to apply the limit. //! - A set of variables. For example, if we need to define the same limit for -//! each "user_id", instead of creating a limit for each hardcoded ID, we just -//! need to define "user_id" as a variable. +//! each "user_id", instead of creating a limit for each hardcoded ID, we just +//! need to define "user_id" as a variable. //! //! If we used Limitador in a context where it receives an HTTP request we could //! define a limit like this to allow 10 requests per minute and per user_id diff --git a/limitador/src/storage/redis/redis_cached.rs b/limitador/src/storage/redis/redis_cached.rs index b23efc67..ee32bc09 100644 --- a/limitador/src/storage/redis/redis_cached.rs +++ b/limitador/src/storage/redis/redis_cached.rs @@ -356,9 +356,8 @@ async fn flush_batcher_and_update_counters( update_counters(&mut redis_conn, counters) }) .await - .map(|res| { + .inspect(|_| { flip_partitioned(&partitioned, false); - res }) .or_else(|(data, err)| { if err.is_transient() {