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 scheduling debounce #479

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ docs
test
.editorconfig
*.tgz
coverage
coverage
examples
6 changes: 1 addition & 5 deletions test/readme.js → examples/readme.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const helper = require('./testHelper')
const { delay } = require('../src/tools')
const helper = require('../test/testHelper')

async function readme () {
const PgBoss = require('../src')
Expand All @@ -20,9 +19,6 @@ async function readme () {
await boss.work(queue, async ([job]) => {
console.log(`received job ${job.id} with data ${JSON.stringify(job.data)}`)
})

await delay(2000)
await boss.stop()
}

readme()
Expand Down
26 changes: 26 additions & 0 deletions examples/schedule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const helper = require('../test/testHelper')

async function schedule () {
const PgBoss = require('../src')
const boss = new PgBoss(helper.getConnectionString())

boss.on('error', console.error)

await boss.start()

const queue = 'scheduled-queue'

await boss.createQueue(queue)

await boss.schedule(queue, '*/2 * * * *', { arg1: 'schedule me' })

await boss.work(queue, async ([job]) => {
console.log(`received job ${job.id} with data ${JSON.stringify(job.data)} on ${new Date().toISOString()}`)
})
}

schedule()
.catch(err => {
console.log(err)
process.exit(1)
})
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pg-boss",
"version": "10.0.4",
"version": "10.0.5",
"description": "Queueing jobs in Postgres from Node.js like a boss",
"main": "./src/index.js",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src/timekeeper.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class Timekeeper extends EventEmitter {
const scheduled = schedules
.filter(i => this.shouldSendIt(i.cron, i.timezone))
.map(({ name, data, options }) =>
({ name: QUEUES.SEND_IT, data: { name, data, options }, options: { singletonKey: name, singletonSeconds: 60 } }))
({ name: QUEUES.SEND_IT, data: { name, data, options }, singletonKey: name, singletonSeconds: 60 }))

if (scheduled.length > 0 && !this.stopped) {
await this.manager.insert(scheduled)
Expand Down