-
-
Notifications
You must be signed in to change notification settings - Fork 271
Expand file tree
/
Copy pathreadme.cjs
More file actions
27 lines (18 loc) · 577 Bytes
/
Copy pathreadme.cjs
File metadata and controls
27 lines (18 loc) · 577 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const { PgBoss } = require('../')
async function readme () {
const boss = new PgBoss('postgres://postgres:postgres@localhost/pgboss')
boss.on('error', console.error)
await boss.start()
const queue = 'readme-queue'
await boss.createQueue(queue)
const id = await boss.send(queue, { arg1: 'read me' })
console.log(`created job ${id} in queue ${queue}`)
await boss.work(queue, async ([job]) => {
console.log(`received job ${job.id} with data ${JSON.stringify(job.data)}`)
})
}
readme()
.catch(err => {
console.log(err)
process.exit(1)
})