Skip to main content

task

Attribute Macro task 

Source
#[task]
Expand description

Derive a task struct and Task impl from an async function.

§Example

#[task(queue = "emails", max_retries = 5)]
async fn send_email(ctx: &TaskContext, to: String, subject: String) -> TaskResult<()> {
    // ...
    Ok(())
}

This generates:

  • struct SendEmail { pub to: String, pub subject: String }
  • impl Task for SendEmail { ... }
  • SendEmail::new(to, subject)