Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix example return value #208

Merged
merged 2 commits into from
Jan 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions example.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const run = async () => {
job.progress(i)
if (Math.random() * 200 < 1) throw new Error(`Random error ${i}`)
}

return { jobId: `This is the return value of job (${job.id})` }
})

const queueScheduler = new QueueScheduler(exampleBullMqName, {
Expand All @@ -42,14 +44,18 @@ const run = async () => {
await job.updateProgress(i)

if (Math.random() * 200 < 1) throw new Error(`Random error ${i}`)

return { jobId: `This is the return value of job (${job.id})` }
}

return { jobId: `This is the return value of job (${job.id})` }
})

app.use('/add', (req, res) => {
const opts = req.query.opts || {}

if (opts.delay) {
opts.delay = +opts.delay * 1000 // delay must be a number
}

exampleBull.add({ title: req.query.title }, opts)
exampleBullMq.add('Add', { title: req.query.title }, opts)

Expand All @@ -66,7 +72,7 @@ const run = async () => {
console.log('To populate the queue, run:')
console.log(' curl http://localhost:3000/add?title=Example')
console.log('To populate the queue with custom options (opts), run:')
console.log(' curl http://localhost:3000/add?title=Test&opts[delay]=900')
console.log(' curl http://localhost:3000/add?title=Test&opts[delay]=10')
})
}

Expand Down