Skip to content

Commit 770e2e2

Browse files
committed
Reorder decode and setStatus also print error on failing to find a job
1 parent f4c480e commit 770e2e2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Sources/JobsPostgres/PostgresJobsQueue.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,17 @@ public final class PostgresJobQueue: JobQueueDriver {
267267
)
268268

269269
do {
270-
try await self.setStatus(jobID: jobID, status: .processing, connection: connection)
271-
// if failed to find a job in the job table try getting another index
272270
guard let buffer = try await stream2.decode(ByteBuffer.self, context: .default).first(where: { _ in true }) else {
271+
logger.error(
272+
"Failed to job with id",
273+
metadata: [
274+
"JobID": "\(jobID)"
275+
]
276+
)
277+
// if failed to find a job in the job table try getting another index
273278
continue
274279
}
280+
try await self.setStatus(jobID: jobID, status: .processing, connection: connection)
275281
do {
276282
let jobInstance = try self.jobRegistry.decode(buffer)
277283
return Result.success(.init(id: jobID, result: .success(jobInstance)))

0 commit comments

Comments
 (0)