Changeset View
Changeset View
Standalone View
Standalone View
services/feature-flags/src/config.rs
use aws_sdk_dynamodb::{Endpoint, Region}; | use aws_sdk_dynamodb::{Endpoint, Region}; | ||||
use clap::{builder::FalseyValueParser, Parser}; | use clap::{builder::FalseyValueParser, Parser}; | ||||
use http::Uri; | use http::Uri; | ||||
use once_cell::sync::Lazy; | use once_cell::sync::Lazy; | ||||
use tracing::info; | use tracing::info; | ||||
use crate::constants::{AWS_REGION, DEFAULT_LOCALSTACK_URL}; | use crate::constants::{ | ||||
AWS_REGION, DEFAULT_LOCALSTACK_URL, HTTP_SERVER_DEFAULT_PORT, | |||||
}; | |||||
#[derive(Parser)] | #[derive(Parser)] | ||||
#[command(version, about, long_about = None)] | #[command(version, about, long_about = None)] | ||||
pub struct AppConfig { | pub struct AppConfig { | ||||
/// Run the service in sandbox | /// Run the service in sandbox | ||||
#[arg(long = "sandbox", default_value_t = false)] | #[arg(long = "sandbox", default_value_t = false)] | ||||
#[arg(value_parser = FalseyValueParser::new())] | #[arg(value_parser = FalseyValueParser::new())] | ||||
pub is_sandbox: bool, | pub is_sandbox: bool, | ||||
/// AWS Localstack service URL, applicable in sandbox mode | /// AWS Localstack service URL, applicable in sandbox mode | ||||
#[arg(long, default_value_t = DEFAULT_LOCALSTACK_URL.to_string())] | #[arg(long, default_value_t = DEFAULT_LOCALSTACK_URL.to_string())] | ||||
pub localstack_url: String, | pub localstack_url: String, | ||||
#[arg(long = "port", default_value_t = HTTP_SERVER_DEFAULT_PORT)] | |||||
pub http_port: u16, | |||||
} | } | ||||
pub static CONFIG: Lazy<AppConfig> = Lazy::new(|| AppConfig::parse()); | pub static CONFIG: Lazy<AppConfig> = Lazy::new(|| AppConfig::parse()); | ||||
pub fn parse_cmdline_args() { | pub fn parse_cmdline_args() { | ||||
Lazy::force(&CONFIG); | Lazy::force(&CONFIG); | ||||
} | } | ||||
Show All 16 Lines |