Skip to content

Async Await Support via AsyncJob

Compare
Choose a tag to compare
@VaporBot VaporBot released this 26 Oct 10:27
· 27 commits to main since this release
09f39d5
This patch was authored by @jdmcd and released by @0xTim.

Adds AsyncJob which allows you to specify a job that has async body implementations:

struct MyJobPayload: Content {
    let name: String
}

struct MyAsyncJob: AsyncJob {
    func dequeue(context: QueueContext, payload: MyJobPayload) async throws {
        print(payload.name)
    }

    func error(context: QueueContext, error: Error, payload: MyJobPayload) async throws {
        print(error)
    }
}

// In configure.swift 
app.queues.add(MyAsyncJob())