From 1b8f3c9bc1febda4db34e53a290cb2c1d8db9bbd Mon Sep 17 00:00:00 2001 From: Joscha Date: Sat, 5 Aug 2023 00:38:57 +0200 Subject: [PATCH] Reorganize config file --- src/config.rs | 13 +++++++++---- src/update.rs | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/config.rs b/src/config.rs index 4ec26ff..2f59d7b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -14,19 +14,24 @@ mod default { } #[derive(Debug, Deserialize)] -pub struct Config { +pub struct Repo { #[serde(default = "default::repo_update_delay", with = "humantime_serde")] - pub repo_update_delay: Duration, + pub update_delay: Duration, } -impl Default for Config { +impl Default for Repo { fn default() -> Self { Self { - repo_update_delay: default::repo_update_delay(), + update_delay: default::repo_update_delay(), } } } +#[derive(Debug, Default, Deserialize)] +pub struct Config { + pub repo: Repo, +} + impl Config { pub fn load(path: &Path) -> anyhow::Result { info!(path = %path.display(), "Loading config"); diff --git a/src/update.rs b/src/update.rs index d01be80..b42cadf 100644 --- a/src/update.rs +++ b/src/update.rs @@ -125,6 +125,6 @@ pub async fn repeatedly(state: AppState) { .instrument(debug_span!("update repo")) .await; - tokio::time::sleep(state.config.repo_update_delay).await; + tokio::time::sleep(state.config.repo.update_delay).await; } }