Skip to content

Commit f833ee7

Browse files
chore: wip
1 parent 5a52888 commit f833ee7

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

storage/framework/core/queue/src/process.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ interface QueuePayload {
99
maxTries: number
1010
timeOut: number | null
1111
timeOutAt: Date | null
12+
payload: any
1213
}
1314

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

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

39-
const payload: QueuePayload = JSON.parse(job.payload)
40+
const body: QueuePayload = JSON.parse(job.payload)
4041
const currentAttempts = job.attempts || 0
4142

42-
log.info(`Running job: ${payload.displayName}`)
43+
log.info(`Running job: ${body.displayName}`)
4344

4445
await updateJobAttempts(job, currentAttempts)
4546

4647
try {
47-
await runJob(payload.name, {
48+
await runJob(body.name, {
4849
queue: job.queue,
49-
payload: {},
50+
payload: body.payload,
5051
context: '',
51-
maxTries: payload.maxTries,
52+
maxTries: body.maxTries,
5253
timeout: 60,
5354
})
5455

5556
await job.delete()
56-
log.info(`Successfully ran job: ${payload.displayName}`)
57+
log.info(`Successfully ran job: ${body.displayName}`)
5758
} catch (error) {
58-
log.error(`Job failed: ${payload.displayName}`, error)
59+
log.error(`Job failed: ${body.displayName}`, error)
5960
}
6061
}
6162
}

storage/framework/core/queue/src/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export async function storeJob(name: string, options: QueueOption): Promise<void
1313
maxTries: options.tries || 1,
1414
timeout: null,
1515
timeoutAt: null,
16+
payload: options.payload || {}
1617
})
1718

1819
const job = {

0 commit comments

Comments
 (0)