Skip to content

Commit bf008ff

Browse files
authored
gc: Run gc in a tokio task to not block main async thread (#37)
1 parent 85bc8e4 commit bf008ff

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

blade/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,15 +345,15 @@ cfg_if! {
345345
if global.retention.is_none() {
346346
continue;
347347
}
348-
let Ok(mut db) = global.db_manager.get() else {
349-
tracing::warn!("Failed to get DB handle for cleanup");
350-
continue;
351-
};
352348
let Some(since) = std::time::SystemTime::now().checked_sub(interval) else {
353349
tracing::warn!("Overflow when clean up time");
354350
continue;
355351
};
356-
tracing::info!("Cleanup result: {:#?}", db.delete_invocations_since(&since));
352+
db::run(global.db_manager.clone(), move |db_mgr| db_mgr.delete_invocations_since(&since)).await.inspect_err(|e| {
353+
tracing::warn!("Failed to mark old invocations for deletion: {e:#?}");
354+
}).ok().inspect(|count| {
355+
tracing::info!("Marked {} invocations for deletion", count);
356+
});
357357
}
358358
}
359359

0 commit comments

Comments
 (0)