ServiceTask

Trait ServiceTask 

Source
pub trait ServiceTask {
    // Required methods
    fn service_name(&self) -> String;
    fn run_service_check<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn should_run(&self) -> bool;

    // Provided method
    fn should_run_last_interval(
        &self,
        last_run: Option<SystemTime>,
        interval: Duration,
    ) -> bool { ... }
}

Required Methods§

Source

fn service_name(&self) -> String

To identify service task

Source

fn run_service_check<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn should_run(&self) -> bool

ServiceTasks are triggered often ( 1s interval ) This method should tell whether run also this ServiceTask in current run.

Provided Methods§

Source

fn should_run_last_interval( &self, last_run: Option<SystemTime>, interval: Duration, ) -> bool

Should run when elapsed time from last run is higher then interval

Implementors§