Skip to content

Commit

Permalink
Updated clap to v4
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsnaps committed Aug 3, 2023
1 parent 5377654 commit 3d91ddc
Show file tree
Hide file tree
Showing 5 changed files with 235 additions and 198 deletions.
158 changes: 93 additions & 65 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion limitador-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ actix-rt = "2"
paperclip = { version = "0.8.0", features = ["actix4"] }
serde = { version = "1", features = ["derive"] }
notify = "6.0.1"
clap = "3.2"
const_format = "0.2.31"
clap = "4.3"

[build-dependencies]
tonic-build = "0.9.2"
4 changes: 3 additions & 1 deletion limitador-server/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ fn generate_protobuf() -> Result<(), Box<dyn Error>> {
}

fn set_features(env: &str) {
let mut features = vec![];
if cfg!(feature = "infinispan") {
println!("cargo:rustc-env={env}=[+infinispan]");
features.push("+infinispan");
}
println!("cargo:rustc-env={env}={features:?}");
}

fn set_profile(env: &str) {
Expand Down
29 changes: 29 additions & 0 deletions limitador-server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,35 @@ pub struct Configuration {
pub rate_limit_headers: RateLimitHeaders,
}

pub mod env {
pub const LIMITS_FILE: Option<&'static str> = option_env!("LIMITS_FILE");

pub const ENVOY_RLS_HOST: Option<&'static str> = option_env!("ENVOY_RLS_HOST");
pub const ENVOY_RLS_PORT: Option<&'static str> = option_env!("ENVOY_RLS_PORT");

pub const HTTP_API_HOST: Option<&'static str> = option_env!("HTTP_API_HOST");
pub const HTTP_API_PORT: Option<&'static str> = option_env!("HTTP_API_PORT");

pub const DISK_PATH: Option<&'static str> = option_env!("DISK_PATH");
pub const DISK_OPTIMIZE: Option<&'static str> = option_env!("DISK_OPTIMIZE");

pub const REDIS_URL: Option<&'static str> = option_env!("REDIS_URL");
pub const REDIS_LOCAL_CACHE_MAX_TTL_CACHED_COUNTERS_MS: Option<&'static str> =
option_env!("REDIS_LOCAL_CACHE_MAX_TTL_CACHED_COUNTERS_MS");
pub const REDIS_LOCAL_CACHE_FLUSHING_PERIOD_MS: Option<&'static str> =
option_env!("REDIS_LOCAL_CACHE_FLUSHING_PERIOD_MS");
pub const REDIS_LOCAL_CACHE_TTL_RATIO_CACHED_COUNTERS: Option<&'static str> =
option_env!("REDIS_LOCAL_CACHE_TTL_RATIO_CACHED_COUNTERS");

pub const RATE_LIMIT_HEADERS: Option<&'static str> = option_env!("RATE_LIMIT_HEADERS");

#[cfg(feature = "infinispan")]
pub const INFINISPAN_CACHE_NAME: Option<&'static str> = option_env!("INFINISPAN_CACHE_NAME");
#[cfg(feature = "infinispan")]
pub const INFINISPAN_COUNTERS_CONSISTENCY: Option<&'static str> =
option_env!("INFINISPAN_COUNTERS_CONSISTENCY");
}

impl Configuration {
pub const DEFAULT_RLS_PORT: &'static str = "8081";
pub const DEFAULT_HTTP_PORT: &'static str = "8080";
Expand Down
Loading

0 comments on commit 3d91ddc

Please sign in to comment.