From f78bbb79e9e7ae7b16368cd075cff82cc129c909 Mon Sep 17 00:00:00 2001 From: Alex Snaps Date: Wed, 15 May 2024 12:59:53 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Infinispan=20feature?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/coverage.yml | 8 - .github/workflows/rust.yml | 8 - Cargo.lock | 131 +------- README.md | 5 - doc/server/configuration.md | 53 ---- limitador-server/Cargo.toml | 3 - limitador-server/build.rs | 9 - limitador-server/sandbox/Makefile | 4 - limitador-server/sandbox/README.md | 1 - .../docker-compose-limitador-infinispan.yaml | 47 --- limitador-server/src/config.rs | 19 -- limitador-server/src/main.rs | 142 +-------- limitador/Cargo.toml | 6 +- limitador/README.md | 4 +- limitador/src/storage/infinispan/counters.rs | 167 ---------- limitador/src/storage/infinispan/dist_lock.rs | 76 ----- .../storage/infinispan/infinispan_storage.rs | 299 ------------------ limitador/src/storage/infinispan/mod.rs | 32 -- limitador/src/storage/infinispan/response.rs | 3 - limitador/src/storage/infinispan/sets.rs | 87 ----- limitador/src/storage/mod.rs | 9 +- limitador/tests/integration_tests.rs | 20 -- 22 files changed, 14 insertions(+), 1119 deletions(-) delete mode 100644 limitador-server/sandbox/docker-compose-limitador-infinispan.yaml delete mode 100644 limitador/src/storage/infinispan/counters.rs delete mode 100644 limitador/src/storage/infinispan/dist_lock.rs delete mode 100644 limitador/src/storage/infinispan/infinispan_storage.rs delete mode 100644 limitador/src/storage/infinispan/mod.rs delete mode 100644 limitador/src/storage/infinispan/response.rs delete mode 100644 limitador/src/storage/infinispan/sets.rs diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index dd7d7bea..ce29448b 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,14 +23,6 @@ jobs: test: name: Test Suite runs-on: ubuntu-latest - services: - infinispan: - image: infinispan/server:11.0.9.Final - ports: - - 11222:11222 - env: - USER: username - PASS: password steps: - uses: actions/checkout@v4 - uses: supercharge/redis-github-action@1.1.0 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a76a191d..86c6195b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -26,14 +26,6 @@ jobs: test: name: Test Suite runs-on: ubuntu-latest - services: - infinispan: - image: infinispan/server:11.0.9.Final - ports: - - 11222:11222 - env: - USER: username - PASS: password steps: - uses: actions/checkout@v4 - uses: supercharge/redis-github-action@1.1.0 diff --git a/Cargo.lock b/Cargo.lock index ae2fd8eb..66c2c852 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -408,12 +408,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - [[package]] name = "base64" version = "0.21.7" @@ -1328,19 +1322,6 @@ dependencies = [ "tokio-io-timeout", ] -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper 0.14.28", - "native-tls", - "tokio", - "tokio-native-tls", -] - [[package]] name = "hyper-tls" version = "0.6.0" @@ -1407,21 +1388,6 @@ dependencies = [ "hashbrown 0.14.3", ] -[[package]] -name = "infinispan" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d961790ad3dae0ea7ec1a4ab2c32de1a0bf5f3d7d7fddb0a0f2059b96ecafe0a" -dependencies = [ - "base64 0.13.1", - "http 0.2.12", - "reqwest", - "serde", - "serde_json", - "thiserror", - "urlencoding", -] - [[package]] name = "inotify" version = "0.9.6" @@ -1587,13 +1553,11 @@ name = "limitador" version = "0.6.0-dev" dependencies = [ "async-trait", - "base64 0.22.0", "cfg-if", "criterion", "dashmap", "futures", "getrandom", - "infinispan", "metrics", "moka", "paste", @@ -1602,7 +1566,6 @@ dependencies = [ "rand", "redis", "redis-test", - "reqwest", "rmp-serde", "rocksdb", "serde", @@ -1740,7 +1703,7 @@ dependencies = [ "base64 0.22.0", "http-body-util", "hyper 1.3.1", - "hyper-tls 0.6.0", + "hyper-tls", "hyper-util", "indexmap 2.2.6", "ipnet", @@ -2599,46 +2562,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" -[[package]] -name = "reqwest" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.28", - "hyper-tls 0.5.0", - "ipnet", - "js-sys", - "log", - "mime", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls-pemfile", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper", - "system-configuration", - "tokio", - "tokio-native-tls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - [[package]] name = "rmp" version = "0.8.12" @@ -2705,15 +2628,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "rustls-pemfile" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" -dependencies = [ - "base64 0.21.7", -] - [[package]] name = "rustversion" version = "1.0.15" @@ -3024,27 +2938,6 @@ dependencies = [ "windows", ] -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "tagptr" version = "0.2.0" @@ -3560,18 +3453,6 @@ dependencies = [ "wasm-bindgen-shared", ] -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "wasm-bindgen-macro" version = "0.2.92" @@ -3810,16 +3691,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "zerocopy" version = "0.7.32" diff --git a/README.md b/README.md index 0618eeb8..d4460f33 100644 --- a/README.md +++ b/README.md @@ -68,11 +68,6 @@ Some tests need a redis deployed in `localhost:6379`. You can run it in Docker w docker run --rm -p 6379:6379 -it redis ``` -Some tests need a infinispan deployed in `localhost:11222`. You can run it in Docker with: -```bash -docker run --rm -p 11222:11222 -it -e USER=username -e PASS=password infinispan/server:11.0.9.Final -``` - Then, run the tests: ```bash diff --git a/doc/server/configuration.md b/doc/server/configuration.md index 2a931eda..7ec1f166 100644 --- a/doc/server/configuration.md +++ b/doc/server/configuration.md @@ -248,31 +248,6 @@ Options: -h, --help Print help ``` -#### `infinispan` optional storage - _experimental_ - -The default binary will _not_ support [Infinispan](https://infinispan.org/) as a storage backend for counters. If you -want to give it a try, you would need to build your own binary of the server using: - -```commandline -cargo build --release --features=infinispan -``` - -Which will add the `infinispan` to the supported `STORAGES`. - -``` -USAGE: - limitador-server infinispan [OPTIONS] - -ARGS: - Infinispan URL to use - -OPTIONS: - -n, --cache-name Name of the cache to store counters in [default: limitador] - -c, --consistency The consistency to use to read from the cache [default: - Strong] [possible values: Strong, Weak] - -h, --help Print help information -``` - For an in-depth coverage of the different topologies supported and how they affect the behavior, see the [topologies' document](../topologies.md). @@ -406,34 +381,6 @@ require Redis. - Format: `enum`: `"debug"`, `"error"`, `"info"`, `"warn"`, or `"trace"`. -### When built with the `infinispan` feature - _experimental_ - -#### `INFINISPAN_CACHE_NAME` - -- The name of the Infinispan cache that Limitador will use to store limits and - counters. This variable applies only when [`INFINISPAN_URL`](#infinispan_url) is - set. -- Optional. By default, Limitador will use a cache called `"limitador"`. -- Format: `string`. - - -#### `INFINISPAN_COUNTERS_CONSISTENCY` - -- Defines the consistency mode for the Infinispan counters created by Limitador. - This variable applies only when [`INFINISPAN_URL`](#infinispan_url) is set. -- Optional. Defaults to `"strong"`. -- Format: `enum`: `"Strong"` or `"Weak"`. - - -#### `INFINISPAN_URL` - -- Infinispan URL. Required only when you want to use Infinispan to store the - limits. -- Optional. By default, Limitador stores the limits in memory and does not - require Infinispan. -- Format: `URL`, in the format of `http://username:password@127.0.0.1:11222`. - - #### `RATE_LIMIT_HEADERS` - Enables rate limit response headers. Only supported by the RLS server. diff --git a/limitador-server/Cargo.toml b/limitador-server/Cargo.toml index 67ae9909..f7b2c146 100644 --- a/limitador-server/Cargo.toml +++ b/limitador-server/Cargo.toml @@ -12,9 +12,6 @@ documentation = "https://kuadrant.io/docs/limitador" readme = "README.md" edition = "2021" -[features] -infinispan = ["limitador/infinispan_storage"] - # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] diff --git a/limitador-server/build.rs b/limitador-server/build.rs index 780efae2..f7a0d811 100644 --- a/limitador-server/build.rs +++ b/limitador-server/build.rs @@ -6,7 +6,6 @@ use std::process::Command; fn main() -> Result<(), Box> { set_git_hash("LIMITADOR_GIT_HASH"); set_profile("LIMITADOR_PROFILE"); - set_features("LIMITADOR_FEATURES"); generate_protobuf() } @@ -26,14 +25,6 @@ fn generate_protobuf() -> Result<(), Box> { Ok(()) } -fn set_features(env: &str) { - let mut features = vec![]; - if cfg!(feature = "infinispan") { - features.push("+infinispan"); - } - println!("cargo:rustc-env={env}={features:?}"); -} - fn set_profile(env: &str) { if let Ok(profile) = std::env::var("PROFILE") { println!("cargo:rustc-env={env}={profile}"); diff --git a/limitador-server/sandbox/Makefile b/limitador-server/sandbox/Makefile index 738adebf..c9f476d6 100644 --- a/limitador-server/sandbox/Makefile +++ b/limitador-server/sandbox/Makefile @@ -45,9 +45,6 @@ deploy-redis-otel: clean ## Uses Redis to store counters, instrumented with open deploy-disk: clean ## Uses disk to store counters $(DOCKER) compose -f docker-compose-envoy.yaml -f docker-compose-limitador-disk.yaml up -deploy-infinispan: clean ## Uses Infinispan to store counters - $(DOCKER) compose -f docker-compose-envoy.yaml -f docker-compose-limitador-infinispan.yaml up - ##@ Helper targets build: ## Build "limitador-testing" image @@ -76,7 +73,6 @@ clean-containers: ## clean containers - $(DOCKER) compose -f docker-compose-envoy.yaml -f docker-compose-limitador-memory.yaml down --volumes --remove-orphans - $(DOCKER) compose -f docker-compose-envoy.yaml -f docker-compose-limitador-redis.yaml down --volumes --remove-orphans - $(DOCKER)_compose -f docker-compose-envoy.yaml -f docker-compose-limitador-redis-cached.yaml down --volumes --remove-orphans - - $(DOCKER) compose -f docker-compose-envoy.yaml -f docker-compose-limitador-infinispan.yaml down --volumes --remove-orphans - $(DOCKER) compose -f docker-compose-envoy.yaml -f docker-compose-limitador-disk.yaml down --volumes --remove-orphans - $(DOCKER) compose -f docker-compose-envoy.yaml -f docker-compose-limitador-redis-otel.yaml down --volumes --remove-orphans - $(MAKE) cleancerts diff --git a/limitador-server/sandbox/README.md b/limitador-server/sandbox/README.md index 56b3acb7..ba62374f 100644 --- a/limitador-server/sandbox/README.md +++ b/limitador-server/sandbox/README.md @@ -24,7 +24,6 @@ Check out `make help` for all the targets. | Redis Secured | `make deploy-redis-tls` | Uses Redis with TLS and password protected to store counters | | Redis Cached | `make deploy-redis-cached` | Uses Redis to store counters, with an in-memory cache | | Redis Otel Instrumented | `make deploy-redis-otel` | Uses redis to store counters, [instrumented with opentelemetry](redis-otel/README.md) | -| Infinispan | `make deploy-infinispan` | Uses Infinispan to store counters | | Disk | `make deploy-disk` | Uses disk to store counters | ### Limitador's admin HTTP endpoint diff --git a/limitador-server/sandbox/docker-compose-limitador-infinispan.yaml b/limitador-server/sandbox/docker-compose-limitador-infinispan.yaml deleted file mode 100644 index 100c693d..00000000 --- a/limitador-server/sandbox/docker-compose-limitador-infinispan.yaml +++ /dev/null @@ -1,47 +0,0 @@ ---- -version: '3.8' -services: - limitador: - image: ${LIMITADOR_IMAGE:-limitador-testing} - depends_on: - infinispan: - condition: service_healthy - command: - - limitador-server - - --rls-ip - - 0.0.0.0 - - --rls-port - - "8081" - - --http-ip - - 0.0.0.0 - - --http-port - - "8080" - - -vvvv - - --grpc-reflection-service - - /opt/kuadrant/limits/limits.yaml - - infinispan - - --cache-name - - "limitador-sandbox" - - --consistency - - "Strong" - - http://username:password@infinispan:11222 - expose: - - "8080" - - "8081" - ports: - - "18080:8080" - - "18081:8081" - volumes: - - ./limits.yaml:/opt/kuadrant/limits/limits.yaml - infinispan: - image: infinispan/server:13.0.10.Final - environment: - USER: username - PASS: password - expose: - - "11222" - healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:11222/rest/v2/cache-managers/default/health/status"] - interval: 30s - timeout: 10s - retries: 5 diff --git a/limitador-server/src/config.rs b/limitador-server/src/config.rs index 7882cd59..949bf446 100644 --- a/limitador-server/src/config.rs +++ b/limitador-server/src/config.rs @@ -7,10 +7,6 @@ // └ REDIS_LOCAL_CACHE_FLUSHING_PERIOD_MS: i64 ?! // └ REDIS_LOCAL_CACHE_BATCH_SIZE: u64 // -// INFINISPAN_URL: StorageType { String } -// └ INFINISPAN_CACHE_NAME: String -// └ INFINISPAN_COUNTERS_CONSISTENCY: enum Consistency { Weak, Strong } -// // ENVOY_RLS_HOST: host // just to become ENVOY_RLS_HOST:ENVOY_RLS_PORT as String // ENVOY_RLS_PORT: port // @@ -59,11 +55,6 @@ pub mod env { pub static ref REDIS_LOCAL_CACHE_BATCH_SIZE: Option<&'static str> = value_for("REDIS_LOCAL_CACHE_BATCH_SIZE"); pub static ref RATE_LIMIT_HEADERS: Option<&'static str> = value_for("RATE_LIMIT_HEADERS"); - pub static ref INFINISPAN_URL: Option<&'static str> = value_for("INFINISPAN_URL"); - pub static ref INFINISPAN_CACHE_NAME: Option<&'static str> = - value_for("INFINISPAN_CACHE_NAME"); - pub static ref INFINISPAN_COUNTERS_CONSISTENCY: Option<&'static str> = - value_for("INFINISPAN_COUNTERS_CONSISTENCY"); } fn value_for(env_key: &'static str) -> Option<&'static str> { @@ -149,8 +140,6 @@ pub enum StorageConfiguration { InMemory(InMemoryStorageConfiguration), Disk(DiskStorageConfiguration), Redis(RedisStorageConfiguration), - #[cfg(feature = "infinispan")] - Infinispan(InfinispanStorageConfiguration), } #[derive(PartialEq, Eq, Debug)] @@ -177,11 +166,3 @@ pub struct RedisStorageCacheConfiguration { pub max_counters: usize, pub response_timeout: u64, } - -#[derive(PartialEq, Eq, Debug)] -#[cfg(feature = "infinispan")] -pub struct InfinispanStorageConfiguration { - pub url: String, - pub cache: Option, - pub consistency: Option, -} diff --git a/limitador-server/src/main.rs b/limitador-server/src/main.rs index 25c6385a..2b9bded1 100644 --- a/limitador-server/src/main.rs +++ b/limitador-server/src/main.rs @@ -5,8 +5,6 @@ extern crate log; extern crate clap; -#[cfg(feature = "infinispan")] -use crate::config::InfinispanStorageConfiguration; use crate::config::{ Configuration, DiskStorageConfiguration, InMemoryStorageConfiguration, RedisStorageCacheConfiguration, RedisStorageConfiguration, StorageConfiguration, @@ -21,8 +19,6 @@ use limitador::counter::Counter; use limitador::errors::LimitadorError; use limitador::limit::Limit; use limitador::storage::disk::DiskStorage; -#[cfg(feature = "infinispan")] -use limitador::storage::infinispan::{Consistency, InfinispanStorageBuilder}; use limitador::storage::redis::{ AsyncRedisStorage, CachedRedisStorage, CachedRedisStorageBuilder, DEFAULT_BATCH_SIZE, DEFAULT_FLUSHING_PERIOD_SEC, DEFAULT_MAX_CACHED_COUNTERS, DEFAULT_RESPONSE_TIMEOUT_MS, @@ -38,7 +34,6 @@ use opentelemetry_otlp::WithExportConfig; use opentelemetry_sdk::propagation::TraceContextPropagator; use opentelemetry_sdk::{trace, Resource}; use prometheus_metrics::PrometheusMetrics; -use std::env::VarError; use std::fmt::Display; use std::fs; use std::path::Path; @@ -62,13 +57,10 @@ pub mod prometheus_metrics; const LIMITADOR_VERSION: &str = env!("CARGO_PKG_VERSION"); const LIMITADOR_PROFILE: &str = env!("LIMITADOR_PROFILE"); -const LIMITADOR_FEATURES: &str = env!("LIMITADOR_FEATURES"); const LIMITADOR_HEADER: &str = "Limitador Server"; #[derive(Error, Debug)] pub enum LimitadorServerError { - #[error("please set either the Redis or the Infinispan URL, but not both")] - IncompatibleStorages, #[error("Invalid limit file: {0}")] ConfigFile(String), #[error("Internal error: {0}")] @@ -90,8 +82,6 @@ impl Limiter { pub async fn new(config: Configuration) -> Result { let rate_limiter = match config.storage { StorageConfiguration::Redis(cfg) => Self::redis_limiter(cfg).await, - #[cfg(feature = "infinispan")] - StorageConfiguration::Infinispan(cfg) => Self::infinispan_limiter(cfg).await, StorageConfiguration::InMemory(cfg) => Self::in_memory_limiter(cfg), StorageConfiguration::Disk(cfg) => Self::disk_limiter(cfg), }; @@ -143,49 +133,6 @@ impl Limiter { }) } - #[cfg(feature = "infinispan")] - async fn infinispan_limiter(cfg: InfinispanStorageConfiguration) -> Self { - use url::Url; - - let parsed_url = Url::parse(&cfg.url).unwrap(); - - let mut builder = InfinispanStorageBuilder::new( - format!( - "{}://{}:{}", - parsed_url.scheme(), - parsed_url.host_str().unwrap(), - parsed_url.port().unwrap(), - ), - parsed_url.username(), - parsed_url.password().unwrap_or_default(), - ); - - let consistency: Option = match cfg.consistency { - Some(cfg_value) => match cfg_value.try_into() { - Ok(consistency) => Some(consistency), - Err(_) => { - eprintln!("Invalid consistency mode, will apply the default"); - None - } - }, - None => None, - }; - - if let Some(consistency) = consistency { - builder = builder.counters_consistency(consistency); - } - - let storage = match &cfg.cache { - Some(cache_name) => builder.cache_name(cache_name).build().await, - None => builder.build().await, - }; - - let rate_limiter_builder = - AsyncRateLimiterBuilder::new(AsyncStorage::with_counter_storage(Box::new(storage))); - - Self::Async(rate_limiter_builder.build()) - } - fn disk_limiter(cfg: DiskStorageConfiguration) -> Self { let storage = match DiskStorage::open(cfg.path.as_str(), cfg.optimization) { Ok(storage) => storage, @@ -417,10 +364,9 @@ async fn main() -> Result<(), Box> { fn create_config() -> (Configuration, &'static str) { let full_version: &'static str = formatcp!( - "v{} ({}) {} {}", + "v{} ({}) {}", LIMITADOR_VERSION, env!("LIMITADOR_GIT_HASH"), - LIMITADOR_FEATURES, LIMITADOR_PROFILE, ); @@ -633,45 +579,6 @@ fn create_config() -> (Configuration, &'static str) { ), ); - #[cfg(feature = "infinispan")] - let cmdline = cmdline.subcommand( - Command::new("infinispan") - .about("Uses Infinispan to store counters") - .display_order(5) - .arg( - Arg::new("URL") - .help("Infinispan URL to use") - .display_order(1) - .required(true) - .index(1), - ) - .arg( - Arg::new("cache name") - .short('n') - .long("cache-name") - .action(ArgAction::Set) - .default_value( - config::env::INFINISPAN_CACHE_NAME - .unwrap_or(storage::infinispan::DEFAULT_INFINISPAN_LIMITS_CACHE_NAME), - ) - .display_order(2) - .help("Name of the cache to store counters in"), - ) - .arg( - Arg::new("consistency") - .short('c') - .long("consistency") - .action(ArgAction::Set) - .default_value( - config::env::INFINISPAN_COUNTERS_CONSISTENCY - .unwrap_or(leak(storage::infinispan::DEFAULT_INFINISPAN_CONSISTENCY)), - ) - .value_parser(clap::builder::PossibleValuesParser::new(["Strong", "Weak"])) - .display_order(3) - .help("The consistency to use to read from the cache"), - ), - ); - let matches = cmdline.get_matches(); let limits_file = matches.get_one::("LIMITS_FILE").unwrap(); @@ -739,24 +646,10 @@ fn create_config() -> (Configuration, &'static str) { response_timeout: *sub.get_one("timeout").unwrap(), }), }), - #[cfg(feature = "infinispan")] - Some(("infinispan", sub)) => { - StorageConfiguration::Infinispan(InfinispanStorageConfiguration { - url: sub.get_one::("URL").unwrap().to_owned(), - cache: Some(sub.get_one::("cache name").unwrap().to_string()), - consistency: Some(sub.get_one::("consistency").unwrap().to_string()), - }) - } Some(("memory", sub)) => StorageConfiguration::InMemory(InMemoryStorageConfiguration { cache_size: sub.get_one::("CACHE_SIZE").copied(), }), - None => match storage_config_from_env() { - Ok(storage_cfg) => storage_cfg, - Err(_) => { - eprintln!("Set either REDIS_URL or INFINISPAN_URL, but not both!"); - process::exit(1); - } - }, + None => storage_config_from_env(), _ => unreachable!("Some storage wasn't configured!"), }; @@ -798,18 +691,10 @@ fn create_config() -> (Configuration, &'static str) { (config, full_version) } -fn storage_config_from_env() -> Result { - let redis_url = config::env::REDIS_URL.ok_or(()); - let infinispan_url = if cfg!(feature = "infinispan") { - config::env::INFINISPAN_URL.ok_or(VarError::NotPresent) - } else { - Err(VarError::NotPresent) - }; - - match (redis_url, infinispan_url) { - (Ok(_), Ok(_)) => Err(()), - (Ok(url), Err(_)) => Ok(StorageConfiguration::Redis(RedisStorageConfiguration { - url: url.to_owned(), +fn storage_config_from_env() -> StorageConfiguration { + if let Some(url) = config::env::REDIS_URL.map(str::to_owned) { + StorageConfiguration::Redis(RedisStorageConfiguration { + url, cache: if *config::env::REDIS_LOCAL_CACHE_ENABLED { Some(RedisStorageCacheConfiguration { batch_size: config::env::REDIS_LOCAL_CACHE_BATCH_SIZE @@ -828,18 +713,9 @@ fn storage_config_from_env() -> Result { } else { None }, - })), - #[cfg(feature = "infinispan")] - (Err(_), Ok(url)) => Ok(StorageConfiguration::Infinispan( - InfinispanStorageConfiguration { - url: url.to_owned(), - cache: config::env::INFINISPAN_CACHE_NAME.map(str::to_owned), - consistency: config::env::INFINISPAN_COUNTERS_CONSISTENCY.map(str::to_owned), - }, - )), - _ => Ok(StorageConfiguration::InMemory( - InMemoryStorageConfiguration { cache_size: None }, - )), + }) + } else { + StorageConfiguration::InMemory(InMemoryStorageConfiguration { cache_size: None }) } } diff --git a/limitador/Cargo.toml b/limitador/Cargo.toml index 0e300804..9bebe4ac 100644 --- a/limitador/Cargo.toml +++ b/limitador/Cargo.toml @@ -12,12 +12,11 @@ documentation = "https://docs.rs/limitador" readme = "README.md" edition = "2021" -# We make redis and infinispan optional to be able to compile for wasm32. +# We make redis optional to be able to compile for wasm32. [features] default = ["disk_storage", "redis_storage"] disk_storage = ["rocksdb"] redis_storage = ["redis", "r2d2", "tokio"] -infinispan_storage = ["infinispan", "reqwest", "base64", "tokio"] lenient_conditions = [] [dependencies] @@ -49,9 +48,6 @@ tokio = { version = "1", optional = true, features = [ "macros", "time", ] } -infinispan = { version = "0.3", optional = true } -reqwest = { version = "0.11", optional = true } -base64 = { version = "0.22", optional = true } [dev-dependencies] serial_test = "3.0" diff --git a/limitador/README.md b/limitador/README.md index 08272038..938c21d2 100644 --- a/limitador/README.md +++ b/limitador/README.md @@ -3,7 +3,7 @@ [![Crates.io](https://img.shields.io/crates/v/limitador)](https://crates.io/crates/limitador) [![docs.rs](https://docs.rs/limitador/badge.svg)](https://docs.rs/limitador) -An embeddable rate-limiter library supporting in-memory, Redis and Infinispan data stores. +An embeddable rate-limiter library supporting in-memory, Redis and disk data stores. Limitador can also be compiled to WebAssembly. For the complete documentation of the crate's API, please refer to [docs.rs](https://docs.rs/limitador/latest/limitador/) @@ -11,7 +11,7 @@ For the complete documentation of the crate's API, please refer to [docs.rs](htt ## Features * `redis_storage`: support for using Redis as the data storage backend. -* `infinispan_storage`: support for using Infinispan as the data storage backend. +* `disk_storage`: support for using RocksDB as a local disk storage backend. * `lenient_conditions`: support for the deprecated syntax of `Condition`s * `default`: `redis_storage`. diff --git a/limitador/src/storage/infinispan/counters.rs b/limitador/src/storage/infinispan/counters.rs deleted file mode 100644 index 9bc24f7d..00000000 --- a/limitador/src/storage/infinispan/counters.rs +++ /dev/null @@ -1,167 +0,0 @@ -// Infinispan does not support counters with TTL. This module provides some -// functions on top of the Infinispan client to be able to work with counters -// with TTLs. -// -// Counters in Infinispan don't have a TTL. So to implement a counter, apart -// from the actual counter, we need a helper key with a TTL that simply tells us -// whether the counter is still valid. -// -// This is how it works in more detail: When a counter is created, apart from -// the actual Infinispan counter, this module creates a regular entry with the -// same name as the counter and with a TTL. The TTL is set to the duration of -// the limit. So, for a limit of 10 requests per minute, the TTL would be a -// minute. While the key has not expired, we know that the value of the counter -// is valid. When the key has expired, the value of the counter no longer -// applies. - -use crate::storage::infinispan::response::response_to_string; -use infinispan::errors::InfinispanError; -use infinispan::{request, Infinispan}; -use std::convert::TryFrom; -use std::fmt::{Display, Formatter}; -use std::time::Duration; -use thiserror::Error; - -#[derive(Copy, Clone)] -pub enum Consistency { - Weak, - Strong, -} - -impl Display for Consistency { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Consistency::Weak => write!(f, "Weak"), - Consistency::Strong => write!(f, "Strong"), - } - } -} - -#[derive(Error, Debug)] -#[error("invalid consistency mode: {mode}")] -pub struct InvalidConsistencyErr { - mode: String, -} - -impl TryFrom for Consistency { - type Error = InvalidConsistencyErr; - - fn try_from(mut value: String) -> Result { - value.make_ascii_lowercase(); - - match value.as_str() { - "weak" => Ok(Self::Weak), - "strong" => Ok(Self::Strong), - _ => Err(InvalidConsistencyErr { mode: value }), - } - } -} - -pub struct CounterOpts { - initial_value: i64, - ttl: Duration, - consistency: Consistency, -} - -impl CounterOpts { - pub fn new(initial_value: i64, ttl: Duration, consistency: Consistency) -> Self { - Self { - initial_value, - ttl, - consistency, - } - } -} - -pub async fn get_value( - infinispan: &Infinispan, - cache_name: impl AsRef, - counter_key: impl AsRef, -) -> Result, InfinispanError> { - let response = infinispan - .run(&request::entries::get(cache_name, &counter_key)) - .await?; - - if response.status() == 404 { - return Ok(None); - } - - let response = infinispan - .run(&request::counters::get(&counter_key)) - .await?; - - // Note: as these operations are not atomic, the counter might have been - // deleted at this point. In that case, the parsing will fail. - match response_to_string(response).await.parse::() { - Ok(val) => Ok(Some(val)), - Err(_) => Ok(None), - } -} - -// Returns a bool that indicates whether the counter was created. -// -// The param "create_counter_opts" specifies the options used to create a -// counter when it's needed (it has expired or was never used). -pub async fn decrement_by( - infinispan: &Infinispan, - cache_name: impl Into, - counter_key: impl Into, - delta: i64, - create_counter_opts: &CounterOpts, -) -> Result { - let cache_name = cache_name.into(); - let counter_key = counter_key.into(); - - let response = infinispan - .run(&request::entries::get(&cache_name, &counter_key)) - .await?; - - if response.status() == 404 { - let reset_resp = infinispan - .run(&request::counters::reset(&counter_key)) - .await?; - - if reset_resp.status() == 404 { - let create_req = match &create_counter_opts.consistency { - Consistency::Weak => request::counters::create_weak(&counter_key), - Consistency::Strong => request::counters::create_strong(&counter_key), - }; - - let _ = infinispan - .run(&create_req.with_value(create_counter_opts.initial_value - delta)) - .await?; - } - - let _ = infinispan - .run( - &request::entries::create(&cache_name, &counter_key) - .with_ttl(create_counter_opts.ttl), - ) - .await?; - - Ok(true) - } else { - // TODO: check other errors - let _ = infinispan - .run(&request::counters::increment(&counter_key).by(-delta)) - .await?; - - Ok(false) - } -} - -pub async fn delete( - infinispan: &Infinispan, - cache_name: impl AsRef, - counter_key: impl AsRef, -) -> Result<(), InfinispanError> { - let _ = infinispan - .run(&request::entries::delete(cache_name, &counter_key)) - .await?; - - let _ = infinispan - .run(&request::counters::delete(&counter_key)) - .await?; - - Ok(()) -} diff --git a/limitador/src/storage/infinispan/dist_lock.rs b/limitador/src/storage/infinispan/dist_lock.rs deleted file mode 100644 index f35d700e..00000000 --- a/limitador/src/storage/infinispan/dist_lock.rs +++ /dev/null @@ -1,76 +0,0 @@ -// Infinispan does not support locks in the REST API. This module adds support -// for them with some caveats. -// -// We use a standard Infinispan entry to simulate a lock. When we need to -// acquire a lock, we try to create an entry with a name that encodes the entry -// that we want to protect. If the call to create the entry fails because it -// already exists, it means that someone else already has the lock. To release -// the lock, we just need to delete the entry that represents it. To avoid -// holding the lock forever, the entry that represents the lock is created with -// a TTL. -// -// Notice that this approach has an important limitation: whatever we do within -// the lock critical section is racing against the TTL, and we cannot guarantee -// that the section will be finished within the limit of the TTL. - -use crate::storage::StorageErr; -use infinispan::errors::InfinispanError; -use infinispan::request; -use infinispan::Infinispan; -use std::time::Duration; - -const RETRIES_INTERVAL: Duration = Duration::from_millis(100); -const RETRIES: u64 = 20; -const LOCK_TTL: Duration = Duration::from_secs(10); - -pub async fn lock( - infinispan: &Infinispan, - cache_name: impl Into, - entry_name: impl Into, -) -> Result<(), StorageErr> { - let cache_name = cache_name.into(); - let entry_name = entry_name.into(); - - let mut retries = 0; - - loop { - let resp = infinispan - .run( - &request::entries::create(cache_name.clone(), lock_name(&entry_name)) - .with_ttl(LOCK_TTL), - ) - .await?; - - let could_create = resp.status().is_success(); - - if could_create { - return Ok(()); - } else { - if retries >= RETRIES { - return Err(StorageErr { - msg: "can't acquire lock".into(), - transient: false, - }); - } - - retries += 1; - - tokio::time::sleep(RETRIES_INTERVAL).await; - } - } -} - -pub async fn release( - infinispan: &Infinispan, - cache_name: impl AsRef, - entry_name: impl AsRef, -) -> Result<(), InfinispanError> { - let _ = infinispan - .run(&request::entries::delete(cache_name, lock_name(entry_name))) - .await?; - Ok(()) -} - -fn lock_name(entry_name: impl AsRef) -> String { - format!("lock:{}", entry_name.as_ref()) -} diff --git a/limitador/src/storage/infinispan/infinispan_storage.rs b/limitador/src/storage/infinispan/infinispan_storage.rs deleted file mode 100644 index 7e521d8a..00000000 --- a/limitador/src/storage/infinispan/infinispan_storage.rs +++ /dev/null @@ -1,299 +0,0 @@ -use crate::counter::Counter; -use crate::limit::Limit; -use crate::storage::infinispan::counters::{Consistency, CounterOpts}; -use crate::storage::infinispan::response::response_to_string; -use crate::storage::infinispan::{ - counters, sets, DEFAULT_INFINISPAN_CONSISTENCY, DEFAULT_INFINISPAN_LIMITS_CACHE_NAME, -}; -use crate::storage::keys::*; -use crate::storage::{AsyncCounterStorage, Authorization, StorageErr}; -use async_trait::async_trait; -use infinispan::errors::InfinispanError; -use infinispan::request; -use infinispan::Infinispan; -use std::collections::HashSet; -use std::time::Duration; - -pub struct InfinispanStorage { - infinispan: Infinispan, - cache_name: String, - counters_consistency: Consistency, -} - -pub struct InfinispanStorageBuilder { - url: String, - username: String, - password: String, - cache_name: Option, - counters_consistency: Option, -} - -#[async_trait] -impl AsyncCounterStorage for InfinispanStorage { - #[tracing::instrument(skip_all)] - async fn is_within_limits(&self, counter: &Counter, delta: i64) -> Result { - let counter_key = key_for_counter(counter); - let counter_val = - counters::get_value(&self.infinispan, &self.cache_name, &counter_key).await?; - - match counter_val { - Some(val) => Ok(val - delta >= 0), - None => Ok(counter.max_value() - delta >= 0), - } - } - - #[tracing::instrument(skip_all)] - async fn update_counter(&self, counter: &Counter, delta: i64) -> Result<(), StorageErr> { - let counter_key = key_for_counter(counter); - - let counter_created = counters::decrement_by( - &self.infinispan, - &self.cache_name, - &counter_key, - delta, - &CounterOpts::new( - counter.max_value(), - Duration::from_secs(counter.seconds()), - self.counters_consistency, - ), - ) - .await?; - - if counter_created { - self.add_to_set(key_for_counters_of_limit(counter.limit()), counter_key) - .await?; - } - - Ok(()) - } - - #[tracing::instrument(skip_all)] - async fn check_and_update<'a>( - &self, - counters: &mut Vec, - delta: i64, - load_counters: bool, - ) -> Result { - let mut counter_keys = Vec::with_capacity(counters.len()); - - if load_counters { - let mut first_limited = None; - for counter in counters.iter_mut() { - let idx = counter_keys.len(); - counter_keys.push(key_for_counter(counter)); - let counter_val = - counters::get_value(&self.infinispan, &self.cache_name, &counter_keys[idx]) - .await?; - - let remaining = counter_val.unwrap_or(counter.max_value()) - delta; - counter.set_remaining(remaining); - - if first_limited.is_none() && remaining < 0 { - first_limited = Some(Authorization::Limited( - counter.limit().name().map(|n| n.to_owned()), - )) - } - } - if let Some(l) = first_limited { - return Ok(l); - } - } else { - for counter in counters.iter() { - if !self.is_within_limits(counter, delta).await? { - return Ok(Authorization::Limited( - counter.limit().name().map(|n| n.to_owned()), - )); - } - counter_keys.push(key_for_counter(counter)); - } - } - - // Update only if all are withing limits - for (counter_idx, counter_key) in counter_keys.into_iter().enumerate() { - let counter = &counters[counter_idx]; - let counter_created = counters::decrement_by( - &self.infinispan, - &self.cache_name, - &counter_key, - delta, - &CounterOpts::new( - counter.max_value(), - Duration::from_secs(counter.seconds()), - self.counters_consistency, - ), - ) - .await?; - - if counter_created { - self.add_to_set(key_for_counters_of_limit(counter.limit()), counter_key) - .await?; - } - } - - Ok(Authorization::Ok) - } - - #[tracing::instrument(skip_all)] - async fn get_counters(&self, limits: HashSet) -> Result, StorageErr> { - let mut res = HashSet::new(); - - for limit in limits { - for counter_key in self.counter_keys_of_limit(&limit).await? { - let counter_val = - counters::get_value(&self.infinispan, &self.cache_name, &counter_key).await?; - - // If the key does not exist, it means that the counter expired, - // so we don't have to return it. - // - // TODO: we should delete the counter from the set of counters - // This does not cause any bugs, but consumes memory - // unnecessarily. - - if let Some(val) = counter_val { - let mut counter: Counter = counter_from_counter_key(&counter_key, &limit); - let ttl = 0; // TODO: calculate TTL from response headers. - counter.set_remaining(val); - counter.set_expires_in(Duration::from_secs(ttl)); - res.insert(counter); - } - } - } - - Ok(res) - } - - #[tracing::instrument(skip_all)] - async fn delete_counters(&self, limits: HashSet) -> Result<(), StorageErr> { - for limit in limits { - self.delete_counters_associated_with_limit(&limit).await?; - } - Ok(()) - } - - #[tracing::instrument(skip_all)] - async fn clear(&self) -> Result<(), StorageErr> { - let _ = self - .infinispan - .run(&request::caches::clear(&self.cache_name)) - .await?; - - let _ = self.delete_all_counters().await?; - - Ok(()) - } -} - -impl InfinispanStorage { - pub async fn new( - url: &str, - username: &str, - password: &str, - cache_name: Option, - counters_consistency: Consistency, - ) -> Self { - let infinispan = Infinispan::new(url, username, password); - - match cache_name { - Some(cache_name) => Self { - infinispan, - cache_name, - counters_consistency, - }, - None => { - let cache_name = DEFAULT_INFINISPAN_LIMITS_CACHE_NAME; - - let _ = infinispan - .run(&request::caches::create_local(cache_name)) - .await - .unwrap(); - - Self { - infinispan, - cache_name: cache_name.into(), - counters_consistency, - } - } - } - } - - async fn delete_counters_associated_with_limit(&self, limit: &Limit) -> Result<(), StorageErr> { - for counter_key in self.counter_keys_of_limit(limit).await? { - counters::delete(&self.infinispan, &self.cache_name, &counter_key).await? - } - - Ok(()) - } - - async fn delete_all_counters(&self) -> Result<(), StorageErr> { - let resp = self.infinispan.run(&request::counters::list()).await?; - - let counter_names: HashSet = - serde_json::from_str(&response_to_string(resp).await).unwrap(); - - for counter_name in counter_names { - let _ = self - .infinispan - .run(&request::counters::delete(counter_name)) - .await?; - } - - Ok(()) - } - - async fn counter_keys_of_limit( - &self, - limit: &Limit, - ) -> Result, InfinispanError> { - self.get_set(key_for_counters_of_limit(limit)).await - } - - async fn get_set(&self, set_key: impl AsRef) -> Result, InfinispanError> { - sets::get(&self.infinispan, &self.cache_name, set_key).await - } - - async fn add_to_set( - &self, - set_key: impl Into, - element: impl Into, - ) -> Result<(), StorageErr> { - sets::add(&self.infinispan, &self.cache_name, set_key, element).await - } -} - -impl InfinispanStorageBuilder { - pub fn new( - url: impl Into, - username: impl Into, - password: impl Into, - ) -> Self { - Self { - url: url.into(), - username: username.into(), - password: password.into(), - cache_name: None, - counters_consistency: None, - } - } - - pub fn cache_name(mut self, cache_name: impl Into) -> Self { - self.cache_name = Some(cache_name.into()); - self - } - - pub fn counters_consistency(mut self, counters_consistency: Consistency) -> Self { - self.counters_consistency = Some(counters_consistency); - self - } - - pub async fn build(self) -> InfinispanStorage { - InfinispanStorage::new( - &self.url, - &self.username, - &self.password, - self.cache_name, - self.counters_consistency - .unwrap_or(DEFAULT_INFINISPAN_CONSISTENCY), - ) - .await - } -} diff --git a/limitador/src/storage/infinispan/mod.rs b/limitador/src/storage/infinispan/mod.rs deleted file mode 100644 index 8289415e..00000000 --- a/limitador/src/storage/infinispan/mod.rs +++ /dev/null @@ -1,32 +0,0 @@ -mod counters; -mod dist_lock; -mod infinispan_storage; -mod response; -mod sets; - -use crate::storage::StorageErr; -pub use counters::Consistency; -use infinispan::errors::InfinispanError; -pub use infinispan_storage::InfinispanStorage; -pub use infinispan_storage::InfinispanStorageBuilder; - -impl From for StorageErr { - fn from(e: reqwest::Error) -> Self { - Self { - msg: e.to_string(), - transient: false, - } - } -} - -impl From for StorageErr { - fn from(e: InfinispanError) -> Self { - Self { - msg: e.to_string(), - transient: false, - } - } -} - -pub const DEFAULT_INFINISPAN_LIMITS_CACHE_NAME: &str = "limitador"; -pub const DEFAULT_INFINISPAN_CONSISTENCY: Consistency = Consistency::Strong; diff --git a/limitador/src/storage/infinispan/response.rs b/limitador/src/storage/infinispan/response.rs deleted file mode 100644 index ce9f4607..00000000 --- a/limitador/src/storage/infinispan/response.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub async fn response_to_string(response: reqwest::Response) -> String { - response.text_with_charset("utf-8").await.unwrap() -} diff --git a/limitador/src/storage/infinispan/sets.rs b/limitador/src/storage/infinispan/sets.rs deleted file mode 100644 index 59767b92..00000000 --- a/limitador/src/storage/infinispan/sets.rs +++ /dev/null @@ -1,87 +0,0 @@ -// Infinispan does not support sets. This module provides some functions on top -// of the Infinispan client to be able to work with sets. - -use crate::storage::infinispan::dist_lock; -use crate::storage::infinispan::response::response_to_string; -use crate::storage::StorageErr; -use infinispan::errors::InfinispanError; -use infinispan::{request, Infinispan}; -use serde_json::json; -use std::collections::HashSet; -use std::iter::FromIterator; - -pub async fn get( - infinispan: &Infinispan, - cache_name: impl AsRef, - set_key: impl AsRef, -) -> Result, InfinispanError> { - let get_entry_response = infinispan - .run(&request::entries::get(cache_name, &set_key)) - .await?; - - let set = if get_entry_response.status() == 404 { - HashSet::new() - } else { - // TODO: handle other errors - serde_json::from_str(&response_to_string(get_entry_response).await).unwrap() - }; - - Ok(set) -} - -// Creates the set if it does not exist. -pub async fn add( - infinispan: &Infinispan, - cache_name: impl Into, - set_key: impl Into, - element: impl Into, -) -> Result<(), StorageErr> { - let cache_name = cache_name.into(); - let set_key = set_key.into(); - let element = element.into(); - - dist_lock::lock(infinispan, &cache_name, &set_key).await?; - - let res = add_set(infinispan, cache_name.clone(), set_key.clone(), element).await; - - dist_lock::release(infinispan, &cache_name, &set_key).await?; - - res -} - -async fn add_set( - infinispan: &Infinispan, - cache_name: String, - set_key: String, - element: String, -) -> Result<(), StorageErr> { - let get_entry_response = infinispan - .run(&request::entries::get(&cache_name, &set_key)) - .await?; - - if get_entry_response.status() == 404 { - let limits_set: HashSet = HashSet::from_iter(vec![element]); - - let _ = infinispan - .run( - &request::entries::create(&cache_name, &set_key) - .with_value(json!(limits_set).to_string()), - ) - .await?; - } else { - // TODO: handle other errors - let mut limits_set: HashSet = - serde_json::from_str(&response_to_string(get_entry_response).await).unwrap(); - limits_set.insert(element); - - let _ = infinispan - .run(&request::entries::update( - &cache_name, - &set_key, - &json!(limits_set).to_string(), - )) - .await?; - } - - Ok(()) -} diff --git a/limitador/src/storage/mod.rs b/limitador/src/storage/mod.rs index eb8c5348..abade6f0 100644 --- a/limitador/src/storage/mod.rs +++ b/limitador/src/storage/mod.rs @@ -14,15 +14,8 @@ pub mod wasm; #[cfg(feature = "redis_storage")] pub mod redis; -#[cfg(feature = "infinispan_storage")] -pub mod infinispan; - mod atomic_expiring_value; -#[cfg(any( - feature = "disk_storage", - feature = "infinispan_storage", - feature = "redis_storage" -))] +#[cfg(any(feature = "disk_storage", feature = "redis_storage"))] mod keys; pub enum Authorization { diff --git a/limitador/tests/integration_tests.rs b/limitador/tests/integration_tests.rs index 7bd8cb7d..ef89c9f8 100644 --- a/limitador/tests/integration_tests.rs +++ b/limitador/tests/integration_tests.rs @@ -68,20 +68,6 @@ macro_rules! test_with_all_storage_impls { ); $function(&mut TestsLimiter::new_from_async_impl(rate_limiter)).await; } - - #[cfg(feature = "infinispan_storage")] - #[tokio::test] - #[serial] - async fn [<$function _with_infinispan>]() { - let storage = InfinispanStorageBuilder::new( - "http://127.0.0.1:11222", "username", "password" - ).build().await; - storage.clear().await.unwrap(); - let rate_limiter = AsyncRateLimiter::new_with_storage( - Box::new(storage) - ); - $function(&mut TestsLimiter::new_from_async_impl(rate_limiter)).await; - } } }; } @@ -106,12 +92,6 @@ mod test { } } - cfg_if::cfg_if! { - if #[cfg(feature = "infinispan_storage")] { - use limitador::storage::infinispan::InfinispanStorageBuilder; - } - } - use self::limitador::counter::Counter; use self::limitador::storage::wasm::Clock; use self::limitador::RateLimiter;