Skip to main content

JobPlugin

Trait JobPlugin 

Source
pub trait JobPlugin {
    // Provided methods
    fn change_status<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _job_id: &'life1 str,
        _status: JobStatus,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: Sync + 'async_trait { ... }
    fn before_run<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _job_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: Sync + 'async_trait { ... }
    fn after_run<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _job_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: Sync + 'async_trait { ... }
}
Expand description

Implement Plugin to catch job hook event

pub struct MyHook;

#[async_trait]
impl JobPlugin for MyHook {
    async fn change_status(&self, job_id: &str, status: JobStatus) {
        println!("Job {job_id} status: {status}");
    }

    async fn before_run(&self, job_id: &str) {
        println!("Before Job {job_id} run");
    }

    async fn after_run(&self, job_id: &str) {
        println!("After Job {job_id} run");
    }
}

AJ::register_plugin(MyHook);

Provided Methods§

Source

fn change_status<'life0, 'life1, 'async_trait>( &'life0 self, _job_id: &'life1 str, _status: JobStatus, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: Sync + 'async_trait,

Source

fn before_run<'life0, 'life1, 'async_trait>( &'life0 self, _job_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: Sync + 'async_trait,

Source

fn after_run<'life0, 'life1, 'async_trait>( &'life0 self, _job_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: Sync + 'async_trait,

Implementors§