Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated clap to v4 #198

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 94 additions & 65 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion limitador-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ 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"
lazy_static = "1.4.0"
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
33 changes: 33 additions & 0 deletions limitador-server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,39 @@ pub struct Configuration {
pub rate_limit_headers: RateLimitHeaders,
}

pub mod env {
use lazy_static::lazy_static;

lazy_static! {
pub static ref LIMITS_FILE: Option<&'static str> = value_for("LIMITS_FILE");
pub static ref ENVOY_RLS_HOST: Option<&'static str> = value_for("ENVOY_RLS_HOST");
pub static ref ENVOY_RLS_PORT: Option<&'static str> = value_for("ENVOY_RLS_PORT");
pub static ref HTTP_API_HOST: Option<&'static str> = value_for("HTTP_API_HOST");
pub static ref HTTP_API_PORT: Option<&'static str> = value_for("HTTP_API_PORT");
pub static ref DISK_PATH: Option<&'static str> = value_for("DISK_PATH");
pub static ref DISK_OPTIMIZE: Option<&'static str> = value_for("DISK_OPTIMIZE");
pub static ref REDIS_URL: Option<&'static str> = value_for("REDIS_URL");
pub static ref REDIS_LOCAL_CACHE_MAX_TTL_CACHED_COUNTERS_MS: Option<&'static str> =
value_for("REDIS_LOCAL_CACHE_MAX_TTL_CACHED_COUNTERS_MS");
pub static ref REDIS_LOCAL_CACHE_FLUSHING_PERIOD_MS: Option<&'static str> =
value_for("REDIS_LOCAL_CACHE_FLUSHING_PERIOD_MS");
pub static ref REDIS_LOCAL_CACHE_TTL_RATIO_CACHED_COUNTERS: Option<&'static str> =
value_for("REDIS_LOCAL_CACHE_TTL_RATIO_CACHED_COUNTERS");
pub static ref RATE_LIMIT_HEADERS: Option<&'static str> = value_for("RATE_LIMIT_HEADERS");
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> {
match std::env::var(env_key) {
Ok(s) => Some(Box::leak(s.into_boxed_str())),
Err(_) => None,
}
}
}

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