Skip to content

Commit 7f51814

Browse files
committed
Adding missing delayed until and fixed sorting order
1 parent 468135a commit 7f51814

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/JobsPostgres/PostgresJobsQueue.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public final class PostgresJobQueue: JobQueueDriver {
228228
let buffer = try self.jobRegistry.encode(jobRequest: jobRequest)
229229
try await self.client.withTransaction(logger: self.logger) { connection in
230230
try await self.updateJob(id: id, buffer: buffer, connection: connection)
231-
try await self.addToQueue(jobID: id, queueName: configuration.queueName, options: .init(), connection: connection)
231+
try await self.addToQueue(jobID: id, queueName: configuration.queueName, options: .init(delayUntil: options.delayUntil), connection: connection)
232232
}
233233
}
234234

@@ -293,7 +293,7 @@ public final class PostgresJobQueue: JobQueueDriver {
293293
FROM swift_jobs.queues
294294
WHERE delayed_until <= NOW()
295295
AND queue_name = \(configuration.queueName)
296-
ORDER BY created_at ASC, delayed_until ASC, priority ASC
296+
ORDER BY priority ASC, delayed_until ASC, created_at ASC
297297
FOR UPDATE SKIP LOCKED
298298
LIMIT 1
299299
)

0 commit comments

Comments
 (0)