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);