Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
glennmichael123 committed Jan 9, 2025
1 parent 5a52888 commit f833ee7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 8 additions & 7 deletions storage/framework/core/queue/src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface QueuePayload {
maxTries: number
timeOut: number | null
timeOutAt: Date | null
payload: any
}

export async function processJobs(queue: string | undefined): Promise<Ok<string, never>> {
Expand Down Expand Up @@ -36,26 +37,26 @@ async function executeJobs(queue: string | undefined): Promise<void> {

if (job.available_at && job.available_at > timestampNow()) continue

const payload: QueuePayload = JSON.parse(job.payload)
const body: QueuePayload = JSON.parse(job.payload)
const currentAttempts = job.attempts || 0

log.info(`Running job: ${payload.displayName}`)
log.info(`Running job: ${body.displayName}`)

await updateJobAttempts(job, currentAttempts)

try {
await runJob(payload.name, {
await runJob(body.name, {
queue: job.queue,
payload: {},
payload: body.payload,
context: '',
maxTries: payload.maxTries,
maxTries: body.maxTries,
timeout: 60,
})

await job.delete()
log.info(`Successfully ran job: ${payload.displayName}`)
log.info(`Successfully ran job: ${body.displayName}`)
} catch (error) {
log.error(`Job failed: ${payload.displayName}`, error)
log.error(`Job failed: ${body.displayName}`, error)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions storage/framework/core/queue/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export async function storeJob(name: string, options: QueueOption): Promise<void
maxTries: options.tries || 1,
timeout: null,
timeoutAt: null,
payload: options.payload || {}
})

const job = {
Expand Down

0 comments on commit f833ee7

Please sign in to comment.