Refactor repo update code again
This commit is contained in:
parent
488ae76c72
commit
b56d0df142
3 changed files with 77 additions and 74 deletions
29
src/recurring.rs
Normal file
29
src/recurring.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
//! Recurring actions and updates.
|
||||
|
||||
// TODO `fetch` submodule for fetching new commits
|
||||
// TODO `queue` submodule for updating the queue
|
||||
|
||||
mod repo;
|
||||
|
||||
use tracing::{debug_span, error, Instrument};
|
||||
|
||||
use crate::state::AppState;
|
||||
|
||||
async fn recurring_task(state: &AppState) {
|
||||
let repo = state.repo.to_thread_local();
|
||||
|
||||
async {
|
||||
if let Err(e) = repo::update(&state.db, &repo).await {
|
||||
error!("Error updating repo:\n{e:?}");
|
||||
};
|
||||
}
|
||||
.instrument(debug_span!("update repo"))
|
||||
.await;
|
||||
}
|
||||
|
||||
pub async fn run(state: AppState) {
|
||||
loop {
|
||||
recurring_task(&state).await;
|
||||
tokio::time::sleep(state.config.repo.update_delay).await;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue