summaryrefslogtreecommitdiff
path: root/crates/bot-jobs/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/bot-jobs/src/lib.rs')
-rw-r--r--crates/bot-jobs/src/lib.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/crates/bot-jobs/src/lib.rs b/crates/bot-jobs/src/lib.rs
new file mode 100644
index 0000000..d65c929
--- /dev/null
+++ b/crates/bot-jobs/src/lib.rs
@@ -0,0 +1,30 @@
+use bot_config::Config;
+use bot_error::Error;
+
+use std::time::Duration;
+
+use log::error;
+
+mod repo;
+
+/// Run our jobs an initial time, then loop them on a separate thread
+///
+/// # Errors
+///
+/// Will return [`Err`] if any jobs fail
+pub fn dispatch(config: Config) -> Result<(), Error> {
+ repo::fetch_or_update_repository(&config.nixpkgs_path, &config.nixpkgs_branches)?;
+
+ tokio::spawn(async move {
+ loop {
+ tokio::time::sleep(Duration::from_secs(repo::TTL_SECS)).await;
+ if let Err(why) =
+ repo::fetch_or_update_repository(&config.nixpkgs_path, &config.nixpkgs_branches)
+ {
+ error!("Failed to fetch or update repository!\n{why:?}");
+ };
+ }
+ });
+
+ Ok(())
+}