Skip to content

Tasks as structs #36

@imbolc

Description

@imbolc

Have you considered representing tasks by structs of their context instead of functions? This way we could avoid explicit context deserialization and related bugs. E.g. this would be impossible:

struct Foo;
struct Bar;

#[job]
pub async fn foo(job: CurrentJob) -> Result<..> {
    let context: Foo = job.json()?;
}
foo.builder().set_json(&Bar).spawn(&db).await?;

It would be something like:

#[derive(Job)]
struct MyJob;

impl CurrentJob for MyJob {
   fn run(self) -> Result<..> {
   }
}

MyJob { ... }.spawn(&db).await?;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions