Skip to content

Commit

Permalink
Fix integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsnaps committed Mar 14, 2024
1 parent 0681e4f commit ca921b2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion limitador-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl Limiter {
};

let mut rate_limiter_builder =
AsyncRateLimiterBuilder::new(AsyncStorage::with_counter_storage(Box::new(storage)));
AsyncRateLimiterBuilder::new(AsyncStorage::with_counter_storage(Arc::new(storage)));

if limit_name_labels {
rate_limiter_builder = rate_limiter_builder.with_prometheus_limit_name_labels()
Expand Down
4 changes: 2 additions & 2 deletions limitador/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
//!
//! async {
//! let rate_limiter = AsyncRateLimiter::new_with_storage(
//! Box::new(AsyncRedisStorage::new("redis://127.0.0.1:7777").await.unwrap())
//! Arc::new(AsyncRedisStorage::new("redis://127.0.0.1:7777").await.unwrap())
//! );

Check failure on line 152 in limitador/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite

failed to resolve: use of undeclared type `Arc`

Check failure on line 152 in limitador/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite

failed to resolve: use of undeclared type `Arc`
//! };
//! # }
Expand All @@ -173,7 +173,7 @@
//!
//! async {
//! let rate_limiter = AsyncRateLimiter::new_with_storage(
//! Box::new(AsyncRedisStorage::new("redis://127.0.0.1:7777").await.unwrap())
//! Arc::new(AsyncRedisStorage::new("redis://127.0.0.1:7777").await.unwrap())
//! );

Check failure on line 177 in limitador/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite

failed to resolve: use of undeclared type `Arc`

Check failure on line 177 in limitador/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite

failed to resolve: use of undeclared type `Arc`
//! rate_limiter.add_limit(limit);
//! };
Expand Down
5 changes: 3 additions & 2 deletions limitador/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ macro_rules! test_with_all_storage_impls {
let storage = AsyncRedisStorage::new("redis://127.0.0.1:6379").await.expect("We need a Redis running locally");
storage.clear().await.unwrap();
let rate_limiter = AsyncRateLimiter::new_with_storage(
Box::new(storage)
Arc::new(storage)
);
AsyncRedisStorage::new("redis://127.0.0.1:6379").await.expect("We need a Redis running locally").clear().await.unwrap();
$function(&mut TestsLimiter::new_from_async_impl(rate_limiter)).await;
Expand All @@ -64,7 +64,7 @@ macro_rules! test_with_all_storage_impls {
).build().await;
storage.clear().await.unwrap();
let rate_limiter = AsyncRateLimiter::new_with_storage(
Box::new(storage)
Arc::new(storage)
);
$function(&mut TestsLimiter::new_from_async_impl(rate_limiter)).await;
}
Expand All @@ -81,6 +81,7 @@ mod test {
// To be able to pass the tests without Redis
cfg_if::cfg_if! {
if #[cfg(feature = "redis_storage")] {
use std::sync::Arc;
use limitador::storage::redis::AsyncRedisStorage;
use limitador::storage::redis::RedisStorage;

Expand Down

0 comments on commit ca921b2

Please sign in to comment.