Skip to content

Commit

Permalink
downgrade to common js for now
Browse files Browse the repository at this point in the history
  • Loading branch information
timgit committed Nov 17, 2022
1 parent a5d4cc4 commit 6e7a077
Show file tree
Hide file tree
Showing 8 changed files with 345 additions and 646 deletions.
955 changes: 333 additions & 622 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pg-boss",
"version": "8.1.1",
"version": "8.2.0",
"description": "Queueing jobs in Node.js using PostgreSQL like a boss",
"main": "./src/index.js",
"engines": {
Expand All @@ -10,9 +10,9 @@
"cron-parser": "^4.0.0",
"delay": "^5.0.0",
"lodash.debounce": "^4.0.8",
"p-map": "^5.3.0",
"p-map": "^4.0.0",
"pg": "^8.5.1",
"serialize-error": "^11.0.0",
"serialize-error": "^8.1.0",
"uuid": "^9.0.0"
},
"devDependencies": {
Expand Down
4 changes: 1 addition & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ class PgBoss extends EventEmitter {
}

async start () {
const { serializeError } = await import('serialize-error')

if (!this.stopped) {
return this
}
Expand All @@ -106,7 +104,7 @@ class PgBoss extends EventEmitter {

this.started = true

this.manager.start({ stringify: serializeError })
this.manager.start()

if (!this.config.noSupervisor) {
await this.boss.supervise()
Expand Down
12 changes: 4 additions & 8 deletions src/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ const EventEmitter = require('events')
const delay = require('delay')
const uuid = require('uuid')
const debounce = require('lodash.debounce')

const { serializeError: stringify } = require('serialize-error')
const Attorney = require('./attorney')
const Worker = require('./worker')
const pMap = require('p-map')

const { QUEUES: BOSS_QUEUES } = require('./boss')
const { QUEUES: TIMEKEEPER_QUEUES } = require('./timekeeper')
Expand Down Expand Up @@ -44,8 +45,6 @@ class Manager extends EventEmitter {
constructor (db, config) {
super()

this.stringify = null

this.config = config
this.db = db

Expand Down Expand Up @@ -98,8 +97,7 @@ class Manager extends EventEmitter {
this.emitWipThrottled = debounce(() => this.emit(events.wip, this.getWipData()), WIP_EVENT_INTERVAL, WIP_DEBOUNCE_OPTIONS)
}

start ({ stringify }) {
this.stringify = stringify
start () {
this.stopping = false
}

Expand Down Expand Up @@ -213,8 +211,6 @@ class Manager extends EventEmitter {
const fetch = () => this.fetch(name, batchSize || (teamSize - queueSize), { includeMetadata })

const onFetch = async (jobs) => {
const { default: pMap } = await import('p-map')

if (this.config.__test__throw_worker) {
throw new Error('__test__throw_worker')
}
Expand Down Expand Up @@ -524,7 +520,7 @@ class Manager extends EventEmitter {
? data
: { value: data }

return this.stringify(result)
return stringify(result)
}

mapCompletionResponse (ids, result) {
Expand Down
3 changes: 1 addition & 2 deletions src/timekeeper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const EventEmitter = require('events')
const plans = require('./plans')
const cronParser = require('cron-parser')
const Attorney = require('./attorney')
const pMap = require('p-map')

const queues = {
CRON: '__pgboss__cron',
Expand Down Expand Up @@ -125,8 +126,6 @@ class Timekeeper extends EventEmitter {
async onCron () {
if (this.stopped) return

const { default: pMap } = await import('p-map')

try {
if (this.config.__test__throw_clock_monitoring) {
throw new Error('clock monitoring error')
Expand Down
3 changes: 1 addition & 2 deletions test/failureTest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const delay = require('delay')
const assert = require('assert')
const helper = require('./testHelper')
const pMap = require('p-map')

describe('failure', function () {
it('should reject missing id argument', async function () {
Expand Down Expand Up @@ -60,8 +61,6 @@ describe('failure', function () {
})

it('should fail a batch of jobs with a data arg', async function () {
const { default: pMap } = await import('p-map')

const boss = this.test.boss = await helper.start(this.test.bossConfig)
const queue = this.test.bossConfig.schema
const message = 'some error'
Expand Down
5 changes: 1 addition & 4 deletions test/multiMasterTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ const PgBoss = require('../')
const Contractor = require('../src/contractor')
const migrationStore = require('../src/migrationStore')
const currentSchemaVersion = require('../version.json').schema
const pMap = require('p-map')

describe('multi-master', function () {
it('should only allow 1 master to start at a time', async function () {
const { default: pMap } = await import('p-map')

const replicaCount = 20
const config = { ...this.test.bossConfig, noSupervisor: true, max: 2 }
const instances = []
Expand All @@ -28,8 +27,6 @@ describe('multi-master', function () {
})

it('should only allow 1 master to migrate to latest at a time', async function () {
const { default: pMap } = await import('p-map')

const replicaCount = 5
const config = { ...this.test.bossConfig, noSupervisor: true, max: 2 }

Expand Down
3 changes: 1 addition & 2 deletions test/speedTest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const helper = require('./testHelper')
const pMap = require('p-map')

describe('speed', function () {
const expectedSeconds = 2
Expand All @@ -12,8 +13,6 @@ describe('speed', function () {
let boss

beforeEach(async function () {
const { default: pMap } = await import('p-map')

const defaults = { noSupervisor: true, min: 10, max: 10 }
boss = await helper.start({ ...this.currentTest.bossConfig, ...defaults })
await pMap(jobs, job => boss.send(job.name, job.data))
Expand Down

0 comments on commit 6e7a077

Please sign in to comment.