[notif] Add clean up timer
This commit is contained in:
@ -4,6 +4,7 @@ use crate::{Error, SharedEnv};
|
||||
use tokio::select;
|
||||
use tokio::sync::{broadcast, mpsc, oneshot};
|
||||
use tokio::task::spawn_local;
|
||||
use tokio::time::{interval, Duration};
|
||||
use tracing::{debug, error, info, trace, warn};
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -138,8 +139,15 @@ struct SubscriptionActor {
|
||||
|
||||
impl SubscriptionActor {
|
||||
async fn run(mut self) {
|
||||
let mut cleanup_timer = interval(Duration::from_secs(3600));
|
||||
loop {
|
||||
select! {
|
||||
_ = cleanup_timer.tick() => {
|
||||
if self.model.retention_hours > 0 {
|
||||
debug!(topic=?self.model.topic, "running retention cleanup");
|
||||
let _ = self.env.db.cleanup_messages(&self.model.server, &self.model.topic);
|
||||
}
|
||||
}
|
||||
Ok(event) = self.listener.events.recv() => {
|
||||
debug!(?event, "received listener event");
|
||||
match event {
|
||||
|
||||
Reference in New Issue
Block a user