Skip to content

Releases: vapor/queues

Allow public access to set ScheduleBuilder Calendar

25 Aug 21:08
8c13f6f
Compare
Choose a tag to compare
This patch was authored by @dylanshine and released by @0xTim.

Adds a new using(_:) API to the ScheduleBuilder to allow the calendar to be set when creating jobs on a schedule

Add ability to use custom `Calendar` in `ScheduleBuilder`

08 Aug 19:43
e2f6c71
Compare
Choose a tag to compare
This patch was authored by @dylanshine and released by @jdmcd.

This PR introduces the ability to pass a custom Calendar to the ScheduleBuilder.

I ran into an edge case where I have queues deployed across multiple regions and needed to schedule jobs based on specific time zones.

I also cleaned up some unused computed properties in the ScheduleBuilderTests suite.

Update Supported Swift Versions

02 Aug 12:27
eab1970
Compare
Choose a tag to compare
This patch was authored and released by @0xTim.

This removes support for Swift 5.2 and Swift 5.3, making Swift 5.4 the earliest supported version as announced

Make AsyncScheduledJob public so clients can conform to it

27 Oct 08:57
58b2d78
Compare
Choose a tag to compare
This patch was authored by @iKenndac and released by @0xTim.

This PR allows client apps to conform to the previously-added AsyncScheduledJob protocol by making it, and the associated adapter function from ScheduledJob, public.

Added AsyncScheduledJob and cleaned up AsyncJob.

27 Oct 00:38
bdb4171
Compare
Choose a tag to compare
This patch was authored by @Andrewangeta and released by @jdmcd.

Allows AsyncJobs to be added to the app via app.queues.add(...) method.

Async Await Support via AsyncJob

26 Oct 10:27
09f39d5
Compare
Choose a tag to compare
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())

Allow delaying retires of failed job

23 Aug 15:09
a0b96a5
Compare
Choose a tag to compare
This patch was authored by @kacperk and released by @jdmcd.

Added possibility of delaying retires of failed jobs.

Example usage

struct SomeJob: Job {
    func dequeue(_ context: QueueContext, _ payload: Payload) -> EventLoopFuture<Void> {
        ....
    }

    // Exponential backoff
    func nextRetryIn(attempt: Int) -> Int {
        return pow(2, attempt)
    }
}

Wait for notifications to be dispatched

23 Jun 18:22
1762fa0
Compare
Choose a tag to compare
This patch was authored and released by @jdmcd.

Fixes a race condition where a job could be marked as "running" in your notification consumer while it had actually succeeded.

Note: If you don't have any notification delegates registered this release will have no performance impact. If you are using notification delegates the dispatch function will now wait until all notifications have been sent to return.

Fix building with Swift 5.2

26 Oct 11:11
9418af4
Compare
Choose a tag to compare
This patch was authored and released by @siemensikkema.

Enables Queues to be built with Swift 5.2 again by adding missing self where needed. Also adds a test scenario for Swift 5.2 to prevent this from breaking in the future.

Job Event Delegate Hooks

11 Oct 22:35
c562842
Compare
Choose a tag to compare
This patch was authored and released by @jdmcd.

This release adds a protocol called JobEventDelegate which allows ends users to "hook" into the status of jobs that are being run. Each notification hook can specify a success handler, an error handler, or both.

To get started, conform an object to JobEventDelegate and implement any of the methods you'd like:

struct MyEventDelegate: JobEventDelegate {
    public func dispatched(job: JobEventData, eventLoop: EventLoop) -> EventLoopFuture<Void> {
        eventLoop.future()
    }

    public func didDequeue(jobId: String, eventLoop: EventLoop) -> EventLoopFuture<Void> {
        eventLoop.future()
    }

    public func success(jobId: String, eventLoop: EventLoop) -> EventLoopFuture<Void> {
        eventLoop.future()
    }

    public func error(jobId: String, error: Error, eventLoop: EventLoop) -> EventLoopFuture<Void> {
        eventLoop.future()
    }
}

Then, add it in your configuration file:

app.queues.add(MyEventDelegate())

This PR also adds a bunch of trace logging for better debugging