scouter_settings/
database.rs1use serde::Serialize;
2
3#[derive(Debug, Clone, Serialize)]
4pub struct DatabaseSettings {
5 pub connection_uri: String,
6 pub max_connections: u32,
7 pub retention_period: i32,
8}
9
10impl Default for DatabaseSettings {
11 fn default() -> Self {
12 let connection_uri = std::env::var("DATABASE_URI")
13 .unwrap_or("postgresql://postgres:postgres@localhost:5432/postgres".to_string());
14
15 let max_connections = std::env::var("MAX_POOL_SIZE")
16 .unwrap_or_else(|_| "30".to_string())
17 .parse::<u32>()
18 .unwrap();
19
20 let retention_period = std::env::var("DATA_RETENTION_PERIOD")
21 .unwrap_or_else(|_| "30".to_string())
22 .parse::<i32>()
23 .unwrap();
24
25 Self {
26 connection_uri,
27 max_connections,
28 retention_period,
29 }
30 }
31}