Skip to content

Releases: vapor/queues

Allow delaying retires of failed job

Choose a tag to compare

@VaporBot VaporBot released this 23 Aug 15:09
a0b96a5
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

Choose a tag to compare

@VaporBot VaporBot released this 23 Jun 18:22
1762fa0
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

Choose a tag to compare

@tanner0101 tanner0101 released this 26 Oct 11:11
9418af4
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

Choose a tag to compare

@tanner0101 tanner0101 released this 11 Oct 22:35
c562842
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

Allow worker count to be configured

Choose a tag to compare

@tanner0101 tanner0101 released this 06 Aug 19:58
649737c
This patch was authored and released by @tanner0101.

Adds a new workerCount property to QueuesConfiguration (#86, fixes #84).

This property lets you configure how many workers will be used for handling jobs. The default value is .default which uses one worker per event loop. You can set a custom number of workings using .custom(_:) or an integer literal.

// Use two workers for handling jobs.
app.queues.configuration.workerCount = 2

Each worker will be assigned an event loop round-robin. If the number of workers is larger than the number of event loops, some event loops will have multiple workers.

Logging metadata improvements

Choose a tag to compare

@tanner0101 tanner0101 released this 24 Jul 13:16
facd81e
This patch was authored by @ileitch and released by @jdmcd.

(#83)

  • Log the job ID rather than the whole struct when a job is dispatched
  • Log the queue name when a job is dequeued
  • Move queue name into metadata for worker starting notice

Print log if scheduled job fails

Choose a tag to compare

@tanner0101 tanner0101 released this 21 Jul 21:06
5f97a2b
This patch was authored and released by @tanner0101.

A log message will now be printed if any ScheduledJob returns a failure (#82).

Allow starting multiple queues in process

Choose a tag to compare

@tanner0101 tanner0101 released this 15 Jul 15:43
0d3a788
This patch was authored and released by @tanner0101.

Adds support for starting multiple queues in process (#80, #76, fixes #75).

In-process queues now have their lifecycle managed by Application.

Add TestQueueStorage.all(_:) to return all jobs for a given job type.

Choose a tag to compare

@tanner0101 tanner0101 released this 03 Jun 15:02
f0c3510
This patch was authored by @ileitch and released by @mcdappdev.

Add TestQueueStorage.all(_:) to return all jobs for a given job type.

Add queue helpers to QueueContext

Choose a tag to compare

@tanner0101 tanner0101 released this 20 May 18:07
e7c0ff0
This patch was authored by @ileitch and released by @tanner0101.

Add queue and queues(_:) helpers to QueueContext so that jobs may also be dispatched from other jobs, just like they are currently dispatched from a Request (#71).