2020-12-24 16:24:04 +01:00
|
|
|
#[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())
|
2020-12-24 16:24:04 +01:00
|
|
|
};
|
|
|
|
Self {
|
|
|
|
concurrency: 2,
|
|
|
|
database_url,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Configuration {
|
2021-01-06 18:47:54 +01:00
|
|
|
crate::rw!("db.toml");
|
2020-12-24 16:24:04 +01:00
|
|
|
}
|
2021-01-06 18:47:54 +01:00
|
|
|
crate::read!(Configuration);
|