pg-boss 8.4.1 → 8.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/attorney.js +8 -0
- package/src/boss.js +16 -8
- package/src/timekeeper.js +2 -2
package/package.json
CHANGED
package/src/attorney.js
CHANGED
|
@@ -387,6 +387,14 @@ function applyMonitoringConfig (config) {
|
|
|
387
387
|
('cronMonitorIntervalSeconds' in config)
|
|
388
388
|
? config.cronMonitorIntervalSeconds
|
|
389
389
|
: 60
|
|
390
|
+
|
|
391
|
+
assert(!('cronWorkerIntervalSeconds' in config) || (config.cronWorkerIntervalSeconds >= 1 && config.cronWorkerIntervalSeconds <= 60),
|
|
392
|
+
'configuration assert: cronWorkerIntervalSeconds must be between 1 and 60 seconds')
|
|
393
|
+
|
|
394
|
+
config.cronWorkerIntervalSeconds =
|
|
395
|
+
('cronWorkerIntervalSeconds' in config)
|
|
396
|
+
? config.cronWorkerIntervalSeconds
|
|
397
|
+
: 4
|
|
390
398
|
}
|
|
391
399
|
|
|
392
400
|
function applyUuidConfig (config) {
|
package/src/boss.js
CHANGED
|
@@ -78,11 +78,19 @@ class Boss extends EventEmitter {
|
|
|
78
78
|
|
|
79
79
|
metaMonitor () {
|
|
80
80
|
this.metaMonitorInterval = setInterval(async () => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
try {
|
|
82
|
+
if (this.config.__test__throw_meta_monitor) {
|
|
83
|
+
throw new Error(this.config.__test__throw_meta_monitor)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const { secondsAgo } = await this.getMaintenanceTime()
|
|
87
|
+
|
|
88
|
+
if (secondsAgo > this.maintenanceIntervalSeconds * 2) {
|
|
89
|
+
await this.manager.deleteQueue(queues.MAINTENANCE, { before: states.completed })
|
|
90
|
+
await this.maintenanceAsync()
|
|
91
|
+
}
|
|
92
|
+
} catch (err) {
|
|
93
|
+
this.emit(events.error, err)
|
|
86
94
|
}
|
|
87
95
|
}, this.maintenanceIntervalSeconds * 2 * 1000)
|
|
88
96
|
}
|
|
@@ -116,7 +124,7 @@ class Boss extends EventEmitter {
|
|
|
116
124
|
async onMaintenance (job) {
|
|
117
125
|
try {
|
|
118
126
|
if (this.config.__test__throw_maint) {
|
|
119
|
-
throw new Error(
|
|
127
|
+
throw new Error(this.config.__test__throw_maint)
|
|
120
128
|
}
|
|
121
129
|
|
|
122
130
|
const started = Date.now()
|
|
@@ -143,7 +151,7 @@ class Boss extends EventEmitter {
|
|
|
143
151
|
async onMonitorStates (job) {
|
|
144
152
|
try {
|
|
145
153
|
if (this.config.__test__throw_monitor) {
|
|
146
|
-
throw new Error(
|
|
154
|
+
throw new Error(this.config.__test__throw_monitor)
|
|
147
155
|
}
|
|
148
156
|
|
|
149
157
|
const states = await this.countStates()
|
|
@@ -161,7 +169,7 @@ class Boss extends EventEmitter {
|
|
|
161
169
|
|
|
162
170
|
async stop () {
|
|
163
171
|
if (this.config.__test__throw_stop) {
|
|
164
|
-
throw new Error(
|
|
172
|
+
throw new Error(this.config.__test__throw_stop)
|
|
165
173
|
}
|
|
166
174
|
|
|
167
175
|
if (!this.stopped) {
|
package/src/timekeeper.js
CHANGED
|
@@ -52,8 +52,8 @@ class Timekeeper extends EventEmitter {
|
|
|
52
52
|
// cache the clock skew from the db server
|
|
53
53
|
await this.cacheClockSkew()
|
|
54
54
|
|
|
55
|
-
await this.manager.work(queues.CRON, { newJobCheckIntervalSeconds:
|
|
56
|
-
await this.manager.work(queues.SEND_IT, { newJobCheckIntervalSeconds:
|
|
55
|
+
await this.manager.work(queues.CRON, { newJobCheckIntervalSeconds: this.config.cronWorkerIntervalSeconds }, (job) => this.onCron(job))
|
|
56
|
+
await this.manager.work(queues.SEND_IT, { newJobCheckIntervalSeconds: this.config.cronWorkerIntervalSeconds, teamSize: 50, teamConcurrency: 5 }, (job) => this.onSendIt(job))
|
|
57
57
|
|
|
58
58
|
// uses sendDebounced() to enqueue a cron check
|
|
59
59
|
await this.checkSchedulesAsync()
|