Skip to main content

job

Attribute Macro job 

Source
#[job]
Expand description

The #[celerix::job] attribute macro.

Place this on your impl Job for MyStruct block. It applies #[typetag::serde] for automatic registration and transforms async fn handle into the required Pin<Box<dyn Future>> form.

§Example

#[derive(Serialize, Deserialize)]
struct SendEmail {
    to: String,
    subject: String,
}

#[celerix::job]
impl celerix::Job for SendEmail {
    async fn handle(self: Box<Self>) -> worker::Result<()> {
        worker::console_log!("Sending email to {}", self.to);
        Ok(())
    }
}