sweeper: tracing span

This commit is contained in:
Zynh Ludwig 2025-01-12 15:26:49 -08:00
parent 0c7f7c3a22
commit 7e8844c89a

View file

@ -1,22 +1,28 @@
use std::time::Duration; use std::time::Duration;
use tracing::{info_span, Instrument};
use crate::state::AppState; use crate::state::AppState;
/// Spawn a repeating task that will clean files periodically /// Spawn a repeating task that will clean files periodically
pub fn spawn(_state: AppState) { pub fn spawn(_state: AppState) {
tokio::spawn(async move { tokio::spawn(
loop { async move {
tokio::time::sleep(Duration::from_secs(15 * 60)).await; loop {
tracing::info!("Cleaning Sweep!"); tokio::time::sleep(Duration::from_secs(15 * 60)).await;
// let mut records = state.records.lock().await; tracing::info!("Cleaning Sweep!");
//
// for (key, record) in records.clone().into_iter() { // let mut records = state.records.lock().await;
// if !record.can_be_downloaded() { //
// tracing::info!("culling: {:?}", record); // for (key, record) in records.clone().into_iter() {
// records.remove_record(&key).await.unwrap(); // if !record.can_be_downloaded() {
// } // tracing::info!("culling: {:?}", record);
// } // records.remove_record(&key).await.unwrap();
// }
// }
}
} }
}); .instrument(info_span!("sweeper")),
);
} }