use crate::AppConfig; impl AppConfig { pub fn database_url(&self) -> anyhow::Result { if let Some(url) = self.env.get("APP_DATABASE_URL") { return Ok(url.to_string()); } Err(anyhow::anyhow!("APP_DATABASE_URL not found")) } pub fn database_max_connections(&self) -> anyhow::Result { if let Some(max_connections) = self.env.get("APP_DATABASE_MAX_CONNECTIONS") { return Ok(max_connections.parse::()?); } Ok(10) } pub fn database_min_connections(&self) -> anyhow::Result { if let Some(min_connections) = self.env.get("APP_DATABASE_MIN_CONNECTIONS") { return Ok(min_connections.parse::()?); } Ok(2) } pub fn database_idle_timeout(&self) -> anyhow::Result { if let Some(idle_timeout) = self.env.get("APP_DATABASE_IDLE_TIMEOUT") { return Ok(idle_timeout.parse::()?); } Ok(60000) } pub fn database_max_lifetime(&self) -> anyhow::Result { if let Some(max_lifetime) = self.env.get("APP_DATABASE_MAX_LIFETIME") { return Ok(max_lifetime.parse::()?); } Ok(300000) } pub fn database_connection_timeout(&self) -> anyhow::Result { if let Some(connection_timeout) = self.env.get("APP_DATABASE_CONNECTION_TIMEOUT") { return Ok(connection_timeout.parse::()?); } Ok(5000) } pub fn database_schema_search_path(&self) -> anyhow::Result { if let Some(schema_search_path) = self.env.get("APP_DATABASE_SCHEMA_SEARCH_PATH") { return Ok(schema_search_path.to_string()); } Ok("public".to_string()) } pub fn database_read_replicas(&self) -> anyhow::Result> { if let Some(replicas) = self.env.get("APP_DATABASE_REPLICAS") { return Ok(replicas.split(',').map(|s| s.to_string()).collect()); } Ok(vec![]) } pub fn database_health_check_interval(&self) -> anyhow::Result { if let Some(interval) = self.env.get("APP_DATABASE_HEALTH_CHECK_INTERVAL") { return Ok(interval.parse::()?); } Ok(30) } pub fn database_retry_attempts(&self) -> anyhow::Result { if let Some(attempts) = self.env.get("APP_DATABASE_RETRY_ATTEMPTS") { return Ok(attempts.parse::()?); } Ok(3) } pub fn database_retry_delay(&self) -> anyhow::Result { if let Some(delay) = self.env.get("APP_DATABASE_RETRY_DELAY") { return Ok(delay.parse::()?); } Ok(5) } }