2021-06-02 01:42:40 +02:00
|
|
|
//! This contains scheduled tasks/interval tasks that are run inside of the server on a schedule
|
|
|
|
//! as background operations.
|
|
|
|
|
2019-10-15 04:34:07 +02:00
|
|
|
use crate::actors::v1_write::QueryServerWriteV1;
|
2020-03-24 23:21:49 +01:00
|
|
|
use crate::constants::PURGE_FREQUENCY;
|
2019-04-18 03:28:33 +02:00
|
|
|
use crate::event::{PurgeRecycledEvent, PurgeTombstoneEvent};
|
2019-02-22 07:15:48 +01:00
|
|
|
|
2020-09-06 00:44:35 +02:00
|
|
|
use tokio::time::{interval, Duration};
|
2019-02-22 07:15:48 +01:00
|
|
|
|
2020-09-06 00:44:35 +02:00
|
|
|
pub struct IntervalActor;
|
2019-02-22 07:15:48 +01:00
|
|
|
|
2020-09-06 00:44:35 +02:00
|
|
|
impl IntervalActor {
|
|
|
|
pub fn start(server: &'static QueryServerWriteV1) {
|
|
|
|
tokio::spawn(async move {
|
|
|
|
let mut inter = interval(Duration::from_secs(PURGE_FREQUENCY));
|
|
|
|
loop {
|
|
|
|
inter.tick().await;
|
|
|
|
server
|
|
|
|
.handle_purgetombstoneevent(PurgeTombstoneEvent::new())
|
|
|
|
.await;
|
|
|
|
server
|
|
|
|
.handle_purgerecycledevent(PurgeRecycledEvent::new())
|
|
|
|
.await;
|
|
|
|
}
|
2019-02-22 07:15:48 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|