-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
Description
Implement a centralized AppConfig struct that loads, validates, and provides all application configuration from environment variables at startup. The service should fail fast with clear error messages if required configuration is missing or invalid.
Requirements:
- Create an
AppConfigstruct inconfig.rs:pub struct AppConfig { pub port: u16, pub stellar_horizon_url: String, pub stellar_secret_key: Option<String>, pub redis_url: String, pub rate_limit_per_second: u32, pub rate_limit_burst: u32, pub stellar_max_retries: u32, pub log_level: String, pub webhook_urls: Vec<String>, pub webhook_secret: Option<String>, pub cache_verification_ttl: u64, }
- Implement
AppConfig::from_env() -> Result<Self, ConfigError>that:- Reads all values from environment variables
- Applies defaults for optional values
- Validates:
stellar_horizon_urlis a valid URL,portis in range1–65535,rate_limit_per_second> 0 - Returns a descriptive
ConfigErrorlisting ALL validation failures at once (not just the first one)
- Replace all
std::env::varcalls scattered inmain.rsand other modules with fields fromAppConfig - Print a startup summary of all resolved configuration values (redacting secrets) at
INFOlevel
Acceptance Criteria:
- Starting with no env vars set uses all defaults and starts successfully
- Setting an invalid URL for
STELLAR_HORIZON_URLcauses a startup failure with a clear message - Multiple validation errors are all reported together
- Secrets (
stellar_secret_key,webhook_secret) are redacted in startup logs (shown as[REDACTED]) - Unit tests for
from_env()covering valid config, missing required fields, and invalid values
Reactions are currently unavailable