vapor / queues

A queue system for Vapor.
MIT License
169 stars 41 forks source link

Async Await Support via AsyncJob #103

Closed jdmcd closed 3 years ago

jdmcd commented 3 years ago

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())
VaporBot commented 3 years ago

These changes are now available in 1.7.0