pg-boss 9.0.3 → 10.0.0-beta10
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/README.md +19 -40
- package/package.json +7 -11
- package/src/attorney.js +81 -105
- package/src/boss.js +88 -139
- package/src/contractor.js +25 -4
- package/src/db.js +14 -8
- package/src/index.js +128 -93
- package/src/manager.js +222 -142
- package/src/migrationStore.js +0 -105
- package/src/plans.js +437 -361
- package/src/timekeeper.js +45 -82
- package/src/tools.js +28 -0
- package/src/worker.js +4 -4
- package/types.d.ts +76 -70
- package/version.json +1 -1
package/src/timekeeper.js
CHANGED
|
@@ -5,7 +5,6 @@ const Attorney = require('./attorney')
|
|
|
5
5
|
const pMap = require('p-map')
|
|
6
6
|
|
|
7
7
|
const queues = {
|
|
8
|
-
CRON: '__pgboss__cron',
|
|
9
8
|
SEND_IT: '__pgboss__send-it'
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -28,11 +27,11 @@ class Timekeeper extends EventEmitter {
|
|
|
28
27
|
this.events = events
|
|
29
28
|
|
|
30
29
|
this.getTimeCommand = plans.getTime(config.schema)
|
|
30
|
+
this.getQueueCommand = plans.getQueueByName(config.schema)
|
|
31
31
|
this.getSchedulesCommand = plans.getSchedules(config.schema)
|
|
32
32
|
this.scheduleCommand = plans.schedule(config.schema)
|
|
33
33
|
this.unscheduleCommand = plans.unschedule(config.schema)
|
|
34
|
-
this.
|
|
35
|
-
this.setCronTimeCommand = plans.setCronTime(config.schema)
|
|
34
|
+
this.trySetCronTimeCommand = plans.trySetCronTime(config.schema)
|
|
36
35
|
|
|
37
36
|
this.functions = [
|
|
38
37
|
this.schedule,
|
|
@@ -49,21 +48,26 @@ class Timekeeper extends EventEmitter {
|
|
|
49
48
|
return
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
|
|
51
|
+
this.stopped = false
|
|
52
|
+
|
|
53
53
|
await this.cacheClockSkew()
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
try {
|
|
56
|
+
await this.manager.createQueue(queues.SEND_IT)
|
|
57
|
+
} catch {}
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
const options = {
|
|
60
|
+
pollingIntervalSeconds: this.config.cronWorkerIntervalSeconds,
|
|
61
|
+
teamSize: 50,
|
|
62
|
+
teamConcurrency: 5
|
|
63
|
+
}
|
|
60
64
|
|
|
61
|
-
|
|
62
|
-
this.cronMonitorInterval = setInterval(async () => await this.monitorCron(), this.cronMonitorIntervalMs)
|
|
63
|
-
// create monitoring interval to measure and adjust for drift in clock skew
|
|
64
|
-
this.skewMonitorInterval = setInterval(async () => await this.cacheClockSkew(), this.skewMonitorIntervalMs)
|
|
65
|
+
await this.manager.work(queues.SEND_IT, options, (job) => this.onSendIt(job))
|
|
65
66
|
|
|
66
|
-
this.
|
|
67
|
+
setImmediate(() => this.onCron())
|
|
68
|
+
|
|
69
|
+
this.cronMonitorInterval = setInterval(async () => await this.onCron(), this.cronMonitorIntervalMs)
|
|
70
|
+
this.skewMonitorInterval = setInterval(async () => await this.cacheClockSkew(), this.skewMonitorIntervalMs)
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
async stop () {
|
|
@@ -73,7 +77,6 @@ class Timekeeper extends EventEmitter {
|
|
|
73
77
|
|
|
74
78
|
this.stopped = true
|
|
75
79
|
|
|
76
|
-
await this.manager.offWork(queues.CRON)
|
|
77
80
|
await this.manager.offWork(queues.SEND_IT)
|
|
78
81
|
|
|
79
82
|
if (this.skewMonitorInterval) {
|
|
@@ -87,22 +90,6 @@ class Timekeeper extends EventEmitter {
|
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
async monitorCron () {
|
|
91
|
-
try {
|
|
92
|
-
if (this.config.__test__force_cron_monitoring_error) {
|
|
93
|
-
throw new Error(this.config.__test__force_cron_monitoring_error)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const { secondsAgo } = await this.getCronTime()
|
|
97
|
-
|
|
98
|
-
if (secondsAgo > 60) {
|
|
99
|
-
await this.checkSchedulesAsync()
|
|
100
|
-
}
|
|
101
|
-
} catch (err) {
|
|
102
|
-
this.emit(this.events.error, err)
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
93
|
async cacheClockSkew () {
|
|
107
94
|
let skew = 0
|
|
108
95
|
|
|
@@ -131,44 +118,36 @@ class Timekeeper extends EventEmitter {
|
|
|
131
118
|
}
|
|
132
119
|
}
|
|
133
120
|
|
|
134
|
-
async checkSchedulesAsync () {
|
|
135
|
-
const opts = {
|
|
136
|
-
retryLimit: 2,
|
|
137
|
-
retentionSeconds: 60,
|
|
138
|
-
onComplete: false
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
await this.manager.sendDebounced(queues.CRON, null, opts, 60)
|
|
142
|
-
}
|
|
143
|
-
|
|
144
121
|
async onCron () {
|
|
145
|
-
if (this.stopped) return
|
|
146
|
-
|
|
147
122
|
try {
|
|
148
|
-
if (this.
|
|
149
|
-
|
|
123
|
+
if (this.stopped || this.timekeeping) return
|
|
124
|
+
|
|
125
|
+
if (this.config.__test__force_cron_monitoring_error) {
|
|
126
|
+
throw new Error(this.config.__test__force_cron_monitoring_error)
|
|
150
127
|
}
|
|
151
128
|
|
|
152
|
-
|
|
129
|
+
this.timekeeping = true
|
|
153
130
|
|
|
154
|
-
const
|
|
131
|
+
const { rows } = await this.db.executeSql(this.trySetCronTimeCommand, [this.config.cronMonitorIntervalSeconds])
|
|
155
132
|
|
|
156
|
-
if (
|
|
157
|
-
await
|
|
133
|
+
if (rows.length === 1 && !this.stopped) {
|
|
134
|
+
await this.cron()
|
|
158
135
|
}
|
|
159
|
-
|
|
160
|
-
if (this.stopped) return
|
|
161
|
-
|
|
162
|
-
// set last time cron was evaluated for downstream usage in cron monitoring
|
|
163
|
-
await this.setCronTime()
|
|
164
136
|
} catch (err) {
|
|
165
137
|
this.emit(this.events.error, err)
|
|
138
|
+
} finally {
|
|
139
|
+
this.timekeeping = false
|
|
166
140
|
}
|
|
141
|
+
}
|
|
167
142
|
|
|
168
|
-
|
|
143
|
+
async cron () {
|
|
144
|
+
const items = await this.getSchedules()
|
|
145
|
+
|
|
146
|
+
const sending = items.filter(i => this.shouldSendIt(i.cron, i.timezone))
|
|
169
147
|
|
|
170
|
-
|
|
171
|
-
|
|
148
|
+
if (sending.length && !this.stopped) {
|
|
149
|
+
await pMap(sending, it => this.send(it), { concurrency: 5 })
|
|
150
|
+
}
|
|
172
151
|
}
|
|
173
152
|
|
|
174
153
|
shouldSendIt (cron, tz) {
|
|
@@ -184,13 +163,7 @@ class Timekeeper extends EventEmitter {
|
|
|
184
163
|
}
|
|
185
164
|
|
|
186
165
|
async send (job) {
|
|
187
|
-
|
|
188
|
-
singletonKey: job.name,
|
|
189
|
-
singletonSeconds: 60,
|
|
190
|
-
onComplete: false
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
await this.manager.send(queues.SEND_IT, job, options)
|
|
166
|
+
await this.manager.send(queues.SEND_IT, job, { singletonKey: job.name, singletonSeconds: 60 })
|
|
194
167
|
}
|
|
195
168
|
|
|
196
169
|
async onSendIt (job) {
|
|
@@ -212,30 +185,20 @@ class Timekeeper extends EventEmitter {
|
|
|
212
185
|
// validation pre-check
|
|
213
186
|
Attorney.checkSendArgs([name, data, options], this.config)
|
|
214
187
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const result = await this.db.executeSql(this.scheduleCommand, values)
|
|
188
|
+
// make sure queue exists before scheduling
|
|
189
|
+
const queue = await this.db.executeSql(this.getQueueCommand, [name])
|
|
218
190
|
|
|
219
|
-
|
|
220
|
-
|
|
191
|
+
if (!queue.rows.length === 0) {
|
|
192
|
+
throw new Error(`Queue '${name}' not found`)
|
|
193
|
+
}
|
|
221
194
|
|
|
222
|
-
|
|
223
|
-
const result = await this.db.executeSql(this.unscheduleCommand, [name])
|
|
224
|
-
return result ? result.rowCount : null
|
|
225
|
-
}
|
|
195
|
+
const values = [name, cron, tz, data, options]
|
|
226
196
|
|
|
227
|
-
|
|
228
|
-
await this.db.executeSql(this.setCronTimeCommand)
|
|
197
|
+
await this.db.executeSql(this.scheduleCommand, values)
|
|
229
198
|
}
|
|
230
199
|
|
|
231
|
-
async
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
let { cron_on: cronOn, seconds_ago: secondsAgo } = rows[0]
|
|
235
|
-
|
|
236
|
-
secondsAgo = secondsAgo !== null ? parseFloat(secondsAgo) : 61
|
|
237
|
-
|
|
238
|
-
return { cronOn, secondsAgo }
|
|
200
|
+
async unschedule (name) {
|
|
201
|
+
await this.db.executeSql(this.unscheduleCommand, [name])
|
|
239
202
|
}
|
|
240
203
|
}
|
|
241
204
|
|
package/src/tools.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
delay
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function delay (ms, error) {
|
|
6
|
+
const { setTimeout } = require('timers/promises')
|
|
7
|
+
const ac = new AbortController()
|
|
8
|
+
|
|
9
|
+
const promise = new Promise((resolve, reject) => {
|
|
10
|
+
setTimeout(ms, null, { signal: ac.signal })
|
|
11
|
+
.then(() => {
|
|
12
|
+
if (error) {
|
|
13
|
+
reject(new Error(error))
|
|
14
|
+
} else {
|
|
15
|
+
resolve()
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
.catch(resolve)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
promise.abort = () => {
|
|
22
|
+
if (!ac.signal.aborted) {
|
|
23
|
+
ac.abort()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return promise
|
|
28
|
+
}
|
package/src/worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const delay = require('
|
|
1
|
+
const { delay } = require('./tools')
|
|
2
2
|
|
|
3
3
|
const WORKER_STATES = {
|
|
4
4
|
created: 'created',
|
|
@@ -34,7 +34,7 @@ class Worker {
|
|
|
34
34
|
this.beenNotified = true
|
|
35
35
|
|
|
36
36
|
if (this.loopDelayPromise) {
|
|
37
|
-
this.loopDelayPromise.
|
|
37
|
+
this.loopDelayPromise.abort()
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -74,7 +74,7 @@ class Worker {
|
|
|
74
74
|
|
|
75
75
|
this.lastJobDuration = duration
|
|
76
76
|
|
|
77
|
-
if (!this.stopping && !this.beenNotified && duration
|
|
77
|
+
if (!this.stopping && !this.beenNotified && (this.interval - duration > 500)) {
|
|
78
78
|
this.loopDelayPromise = delay(this.interval - duration)
|
|
79
79
|
await this.loopDelayPromise
|
|
80
80
|
this.loopDelayPromise = null
|
|
@@ -91,7 +91,7 @@ class Worker {
|
|
|
91
91
|
this.state = WORKER_STATES.stopping
|
|
92
92
|
|
|
93
93
|
if (this.loopDelayPromise) {
|
|
94
|
-
this.loopDelayPromise.
|
|
94
|
+
this.loopDelayPromise.abort()
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import { EventEmitter } from 'events'
|
|
2
2
|
|
|
3
3
|
declare namespace PgBoss {
|
|
4
|
+
|
|
5
|
+
type JobStates = {
|
|
6
|
+
created : 'created',
|
|
7
|
+
retry: 'retry',
|
|
8
|
+
active: 'active',
|
|
9
|
+
completed: 'completed',
|
|
10
|
+
cancelled: 'cancelled',
|
|
11
|
+
failed: 'failed'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type QueuePolicies = {
|
|
15
|
+
standard: 'standard'
|
|
16
|
+
short: 'short',
|
|
17
|
+
singleton: 'singleton',
|
|
18
|
+
stately: 'stately'
|
|
19
|
+
}
|
|
4
20
|
interface Db {
|
|
5
|
-
executeSql(text: string, values: any[]): Promise<{ rows: any[]
|
|
21
|
+
executeSql(text: string, values: any[]): Promise<{ rows: any[] }>;
|
|
6
22
|
}
|
|
7
23
|
|
|
8
24
|
interface DatabaseOptions {
|
|
@@ -20,20 +36,20 @@ declare namespace PgBoss {
|
|
|
20
36
|
}
|
|
21
37
|
|
|
22
38
|
interface QueueOptions {
|
|
23
|
-
uuid?: "v1" | "v4";
|
|
24
39
|
monitorStateIntervalSeconds?: number;
|
|
25
40
|
monitorStateIntervalMinutes?: number;
|
|
26
41
|
}
|
|
27
42
|
|
|
28
43
|
interface SchedulingOptions {
|
|
29
|
-
|
|
44
|
+
schedule?: boolean;
|
|
30
45
|
|
|
31
46
|
clockMonitorIntervalSeconds?: number;
|
|
32
47
|
clockMonitorIntervalMinutes?: number;
|
|
33
48
|
}
|
|
34
49
|
|
|
35
50
|
interface MaintenanceOptions {
|
|
36
|
-
|
|
51
|
+
supervise?: boolean;
|
|
52
|
+
migrate?: boolean;
|
|
37
53
|
|
|
38
54
|
deleteAfterSeconds?: number;
|
|
39
55
|
deleteAfterMinutes?: number;
|
|
@@ -56,11 +72,6 @@ declare namespace PgBoss {
|
|
|
56
72
|
& RetentionOptions
|
|
57
73
|
& RetryOptions
|
|
58
74
|
& JobPollingOptions
|
|
59
|
-
& CompletionOptions
|
|
60
|
-
|
|
61
|
-
interface CompletionOptions {
|
|
62
|
-
onComplete?: boolean;
|
|
63
|
-
}
|
|
64
75
|
|
|
65
76
|
interface ExpirationOptions {
|
|
66
77
|
expireInSeconds?: number;
|
|
@@ -82,34 +93,38 @@ declare namespace PgBoss {
|
|
|
82
93
|
}
|
|
83
94
|
|
|
84
95
|
interface JobOptions {
|
|
96
|
+
id?: string,
|
|
85
97
|
priority?: number;
|
|
86
98
|
startAfter?: number | string | Date;
|
|
87
99
|
singletonKey?: string;
|
|
88
|
-
useSingletonQueue?: boolean;
|
|
89
100
|
singletonSeconds?: number;
|
|
90
101
|
singletonMinutes?: number;
|
|
91
102
|
singletonHours?: number;
|
|
92
103
|
singletonNextSlot?: boolean;
|
|
104
|
+
deadLetter?: string;
|
|
93
105
|
}
|
|
94
106
|
|
|
95
107
|
interface ConnectionOptions {
|
|
96
108
|
db?: Db;
|
|
97
109
|
}
|
|
98
|
-
|
|
110
|
+
|
|
99
111
|
type InsertOptions = ConnectionOptions;
|
|
100
|
-
|
|
101
|
-
type SendOptions = JobOptions & ExpirationOptions & RetentionOptions & RetryOptions &
|
|
112
|
+
|
|
113
|
+
type SendOptions = JobOptions & ExpirationOptions & RetentionOptions & RetryOptions & ConnectionOptions;
|
|
114
|
+
|
|
115
|
+
type QueuePolicy = 'standard' | 'short' | 'singleton' | 'stately'
|
|
116
|
+
type Queue = ExpirationOptions & RetentionOptions & RetryOptions & { policy: QueuePolicy }
|
|
117
|
+
type QueueUpdateOptions = ExpirationOptions & RetentionOptions & RetryOptions
|
|
102
118
|
|
|
103
119
|
type ScheduleOptions = SendOptions & { tz?: string }
|
|
104
120
|
|
|
105
121
|
interface JobPollingOptions {
|
|
106
|
-
|
|
107
|
-
newJobCheckIntervalSeconds?: number;
|
|
122
|
+
pollingIntervalSeconds?: number;
|
|
108
123
|
}
|
|
109
124
|
|
|
110
125
|
interface CommonJobFetchOptions {
|
|
111
126
|
includeMetadata?: boolean;
|
|
112
|
-
|
|
127
|
+
priority?: boolean;
|
|
113
128
|
}
|
|
114
129
|
|
|
115
130
|
type JobFetchOptions = CommonJobFetchOptions & {
|
|
@@ -127,7 +142,6 @@ declare namespace PgBoss {
|
|
|
127
142
|
|
|
128
143
|
type FetchOptions = {
|
|
129
144
|
includeMetadata?: boolean;
|
|
130
|
-
enforceSingletonQueueActiveLimit?: boolean;
|
|
131
145
|
} & ConnectionOptions;
|
|
132
146
|
|
|
133
147
|
interface WorkHandler<ReqData> {
|
|
@@ -181,24 +195,26 @@ declare namespace PgBoss {
|
|
|
181
195
|
data: T;
|
|
182
196
|
}
|
|
183
197
|
|
|
184
|
-
interface JobWithMetadata<T = object>
|
|
198
|
+
interface JobWithMetadata<T = object> {
|
|
199
|
+
id: string;
|
|
200
|
+
name: string;
|
|
201
|
+
data: T;
|
|
185
202
|
priority: number;
|
|
186
|
-
state: 'created' | 'retry' | 'active' | 'completed' | '
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
oncomplete: boolean,
|
|
203
|
+
state: 'created' | 'retry' | 'active' | 'completed' | 'cancelled' | 'failed';
|
|
204
|
+
retryLimit: number;
|
|
205
|
+
retryCount: number;
|
|
206
|
+
retryDelay: number;
|
|
207
|
+
retryBackoff: boolean;
|
|
208
|
+
startAfter: Date;
|
|
209
|
+
startedOn: Date;
|
|
210
|
+
singletonKey: string | null;
|
|
211
|
+
singletonOn: Date | null;
|
|
212
|
+
expireIn: PostgresInterval;
|
|
213
|
+
createdOn: Date;
|
|
214
|
+
completedOn: Date | null;
|
|
215
|
+
keepUntil: Date;
|
|
216
|
+
deadLetter: string,
|
|
217
|
+
policy: QueuePolicy,
|
|
202
218
|
output: object
|
|
203
219
|
}
|
|
204
220
|
|
|
@@ -214,7 +230,7 @@ declare namespace PgBoss {
|
|
|
214
230
|
singletonKey?: string;
|
|
215
231
|
expireInSeconds?: number;
|
|
216
232
|
keepUntil?: Date | string;
|
|
217
|
-
|
|
233
|
+
deadLetter?: string;
|
|
218
234
|
}
|
|
219
235
|
|
|
220
236
|
interface MonitorState {
|
|
@@ -223,7 +239,6 @@ declare namespace PgBoss {
|
|
|
223
239
|
retry: number;
|
|
224
240
|
active: number;
|
|
225
241
|
completed: number;
|
|
226
|
-
expired: number;
|
|
227
242
|
cancelled: number;
|
|
228
243
|
failed: number;
|
|
229
244
|
}
|
|
@@ -236,7 +251,7 @@ declare namespace PgBoss {
|
|
|
236
251
|
id: string,
|
|
237
252
|
name: string,
|
|
238
253
|
options: WorkOptions,
|
|
239
|
-
state: 'created' | '
|
|
254
|
+
state: 'created' | 'active' | 'stopping' | 'stopped'
|
|
240
255
|
count: number,
|
|
241
256
|
createdOn: Date,
|
|
242
257
|
lastFetchedOn: Date,
|
|
@@ -250,7 +265,8 @@ declare namespace PgBoss {
|
|
|
250
265
|
interface StopOptions {
|
|
251
266
|
destroy?: boolean,
|
|
252
267
|
graceful?: boolean,
|
|
253
|
-
timeout?: number
|
|
268
|
+
timeout?: number,
|
|
269
|
+
wait?: boolean
|
|
254
270
|
}
|
|
255
271
|
|
|
256
272
|
interface OffWorkOptions {
|
|
@@ -274,6 +290,9 @@ declare class PgBoss extends EventEmitter {
|
|
|
274
290
|
static getRollbackPlans(schema: string): string;
|
|
275
291
|
static getRollbackPlans(): string;
|
|
276
292
|
|
|
293
|
+
static states: PgBoss.JobStates
|
|
294
|
+
static policies: PgBoss.QueuePolicies
|
|
295
|
+
|
|
277
296
|
on(event: "error", handler: (error: Error) => void): this;
|
|
278
297
|
off(event: "error", handler: (error: Error) => void): this;
|
|
279
298
|
|
|
@@ -300,10 +319,6 @@ declare class PgBoss extends EventEmitter {
|
|
|
300
319
|
sendAfter(name: string, data: object, options: PgBoss.SendOptions, dateString: string): Promise<string | null>;
|
|
301
320
|
sendAfter(name: string, data: object, options: PgBoss.SendOptions, seconds: number): Promise<string | null>;
|
|
302
321
|
|
|
303
|
-
sendOnce(name: string, data: object, options: PgBoss.SendOptions, key: string): Promise<string | null>;
|
|
304
|
-
|
|
305
|
-
sendSingleton(name: string, data: object, options: PgBoss.SendOptions): Promise<string | null>;
|
|
306
|
-
|
|
307
322
|
sendThrottled(name: string, data: object, options: PgBoss.SendOptions, seconds: number): Promise<string | null>;
|
|
308
323
|
sendThrottled(name: string, data: object, options: PgBoss.SendOptions, seconds: number, key: string): Promise<string | null>;
|
|
309
324
|
|
|
@@ -320,16 +335,9 @@ declare class PgBoss extends EventEmitter {
|
|
|
320
335
|
work<ReqData>(name: string, options: PgBoss.BatchWorkOptions & { includeMetadata: true }, handler: PgBoss.BatchWorkWithMetadataHandler<ReqData>): Promise<string>;
|
|
321
336
|
work<ReqData>(name: string, options: PgBoss.BatchWorkOptions, handler: PgBoss.BatchWorkHandler<ReqData>): Promise<string>;
|
|
322
337
|
|
|
323
|
-
onComplete(name: string, handler: Function): Promise<string>;
|
|
324
|
-
onComplete(name: string, options: PgBoss.WorkOptions, handler: Function): Promise<string>;
|
|
325
|
-
|
|
326
338
|
offWork(name: string): Promise<void>;
|
|
327
339
|
offWork(options: PgBoss.OffWorkOptions): Promise<void>;
|
|
328
340
|
|
|
329
|
-
/**
|
|
330
|
-
* Notify worker that something has changed
|
|
331
|
-
* @param workerId
|
|
332
|
-
*/
|
|
333
341
|
notifyWorker(workerId: string): void;
|
|
334
342
|
|
|
335
343
|
subscribe(event: string, name: string): Promise<void>;
|
|
@@ -338,43 +346,41 @@ declare class PgBoss extends EventEmitter {
|
|
|
338
346
|
publish(event: string, data: object): Promise<string[]>;
|
|
339
347
|
publish(event: string, data: object, options: PgBoss.SendOptions): Promise<string[]>;
|
|
340
348
|
|
|
341
|
-
offComplete(name: string): Promise<void>;
|
|
342
|
-
offComplete(options: PgBoss.OffWorkOptions): Promise<void>;
|
|
343
|
-
|
|
344
349
|
fetch<T>(name: string): Promise<PgBoss.Job<T> | null>;
|
|
345
350
|
fetch<T>(name: string, batchSize: number): Promise<PgBoss.Job<T>[] | null>;
|
|
346
351
|
fetch<T>(name: string, batchSize: number, options: PgBoss.FetchOptions & { includeMetadata: true }): Promise<PgBoss.JobWithMetadata<T>[] | null>;
|
|
347
352
|
fetch<T>(name: string, batchSize: number, options: PgBoss.FetchOptions): Promise<PgBoss.Job<T>[] | null>;
|
|
348
353
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
fetchCompleted<T>(name: string, batchSize: number, options: PgBoss.FetchOptions & { includeMetadata: true }): Promise<PgBoss.JobWithMetadata<T>[] | null>;
|
|
352
|
-
fetchCompleted<T>(name: string, batchSize: number, options: PgBoss.FetchOptions): Promise<PgBoss.Job<T>[] | null>;
|
|
353
|
-
|
|
354
|
-
cancel(id: string, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
355
|
-
cancel(ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
354
|
+
cancel(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
355
|
+
cancel(name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
356
356
|
|
|
357
|
-
resume(id: string, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
358
|
-
resume(ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
357
|
+
resume(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
358
|
+
resume(name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
359
359
|
|
|
360
|
-
complete(id: string, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
361
|
-
complete(id: string, data: object, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
362
|
-
complete(ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
360
|
+
complete(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
361
|
+
complete(name: string, id: string, data: object, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
362
|
+
complete(name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
363
363
|
|
|
364
|
-
fail(id: string, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
365
|
-
fail(id: string, data: object, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
366
|
-
fail(ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
364
|
+
fail(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
365
|
+
fail(name: string, id: string, data: object, options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
366
|
+
fail(name: string, ids: string[], options?: PgBoss.ConnectionOptions): Promise<void>;
|
|
367
367
|
|
|
368
368
|
getQueueSize(name: string, options?: object): Promise<number>;
|
|
369
|
-
getJobById(id: string, options?: PgBoss.ConnectionOptions): Promise<PgBoss.JobWithMetadata | null>;
|
|
369
|
+
getJobById(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<PgBoss.JobWithMetadata | null>;
|
|
370
370
|
|
|
371
|
+
createQueue(name: string, options?: PgBoss.Queue): Promise<void>;
|
|
372
|
+
getQueue(name: string): Promise<PgBoss.Queue | null>;
|
|
373
|
+
updateQueue(name: string, options?: PgBoss.QueueUpdateOptions): Promise<void>;
|
|
371
374
|
deleteQueue(name: string): Promise<void>;
|
|
372
|
-
|
|
373
|
-
clearStorage(): Promise<void>;
|
|
375
|
+
purgeQueue(name: string): Promise<void>;
|
|
374
376
|
|
|
377
|
+
clearStorage(): Promise<void>;
|
|
375
378
|
archive(): Promise<void>;
|
|
376
379
|
purge(): Promise<void>;
|
|
377
380
|
expire(): Promise<void>;
|
|
381
|
+
maintain(): Promise<void>;
|
|
382
|
+
isInstalled(): Promise<Boolean>;
|
|
383
|
+
schemaVersion(): Promise<Number>;
|
|
378
384
|
|
|
379
385
|
schedule(name: string, cron: string, data?: object, options?: PgBoss.ScheduleOptions): Promise<void>;
|
|
380
386
|
unschedule(name: string): Promise<void>;
|
package/version.json
CHANGED