bitque/shared/jirs-config/src/database.rs

26 lines
638 B
Rust
Raw Normal View History

#[derive(serde::Serialize, serde::Deserialize)]
pub struct Configuration {
pub concurrency: usize,
pub database_url: String,
}
impl Default for Configuration {
fn default() -> Self {
let database_url = if cfg!(test) {
"postgres://postgres@localhost:5432/jirs_test".to_string()
} else {
std::env::var("DATABASE_URL")
2020-12-24 16:24:47 +01:00
.unwrap_or_else(|_| "postgres://postgres@localhost:5432/jirs".to_string())
};
Self {
concurrency: 2,
database_url,
}
}
}
impl Configuration {
crate::rw!("db.toml");
}
crate::read!(Configuration);