use std::time::Duration; use actix::{Actor, Addr, AsyncContext, Context, Handler, SyncContext}; use background_jobs_core::Storage; use crate::{CheckDb, ProcessJob, Server}; pub struct Pinger where S: Storage + 'static, W: Actor + Handler, { server: Addr>, } impl Pinger where S: Storage + 'static, W: Actor + Handler, { pub fn new(server: Addr>) -> Self { Pinger { server } } } impl Actor for Pinger where S: Storage + 'static, W: Actor + Handler, Server: Actor>> + Handler, { type Context = Context; fn started(&mut self, ctx: &mut Self::Context) { ctx.run_interval(Duration::from_secs(1), |actor, _| { actor.server.do_send(CheckDb); }); } }