Skip to main content

veilid_core/table_store/tasks/
mod.rs

1pub mod cleanup_tables;
2pub mod flush_tables;
3
4use super::*;
5
6impl TableStore {
7    pub(super) fn setup_tasks(&self) {
8        // Set flush tables tick task
9        veilid_log!(self debug "starting flush tables task");
10        impl_setup_task_async!(self, Self, flush_tables_task, flush_tables_task_routine);
11
12        // Set cleanup tables tick task
13        veilid_log!(self debug "starting cleanup tables task");
14        impl_setup_task_async!(self, Self, cleanup_tables_task, cleanup_tables_task_routine);
15    }
16
17    #[cfg_attr(feature = "instrument", instrument(parent = None, level = "trace", target = "tstore", name = "TableStore::tick", skip_all, err))]
18    pub async fn tick(&self, _lag: Option<TimestampDuration>) -> EyreResult<()> {
19        // Run the flush tables task
20        self.flush_tables_task.tick().await?;
21
22        // Run the cleanup tables task
23        self.cleanup_tables_task.tick().await?;
24
25        Ok(())
26    }
27
28    #[cfg_attr(
29        feature = "instrument",
30        instrument(level = "trace", target = "stor", skip_all)
31    )]
32    pub(super) async fn cancel_tasks(&self) {
33        veilid_log!(self debug "stopping flush tables task");
34        if let Err(e) = self.flush_tables_task.stop().await {
35            veilid_log!(self warn "flush_tables_task not stopped: {}", e);
36        }
37        veilid_log!(self debug "stopping cleanup tables task");
38        if let Err(e) = self.cleanup_tables_task.stop().await {
39            veilid_log!(self warn "cleanup_tables_task not stopped: {}", e);
40        }
41    }
42}