@pikku/queue-pg-boss 0.9.2 → 0.9.4
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/CHANGELOG.md +16 -0
- package/package.json +2 -2
- package/src/pg-boss-queue-worker.ts +25 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @pikku/queue-pg-boss
|
|
2
2
|
|
|
3
|
+
## 0.9.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3bb5824: fix: forcing release to see if dist is generated
|
|
8
|
+
- Updated dependencies [99c2b3a]
|
|
9
|
+
- @pikku/core@0.9.9
|
|
10
|
+
|
|
11
|
+
## 0.9.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- c18800d: feat: adding queue and scheduledTask to interactions
|
|
16
|
+
- Updated dependencies [c18800d]
|
|
17
|
+
- @pikku/core@0.9.4
|
|
18
|
+
|
|
3
19
|
## 0.9.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/queue-pg-boss",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"author": "yasser.fadl@gmail.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"release": "npm run build && npm test"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"@pikku/core": "^0.9.
|
|
16
|
+
"@pikku/core": "^0.9.9"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"pg-boss": "^10.3.2"
|
|
@@ -5,7 +5,12 @@ import type {
|
|
|
5
5
|
QueueConfigMapping,
|
|
6
6
|
ConfigValidationResult,
|
|
7
7
|
} from '@pikku/core/queue'
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
runQueueJob,
|
|
10
|
+
registerQueueWorkers,
|
|
11
|
+
QueueJobFailedError,
|
|
12
|
+
QueueJobDiscardedError,
|
|
13
|
+
} from '@pikku/core/queue'
|
|
9
14
|
import {
|
|
10
15
|
CoreServices,
|
|
11
16
|
CoreSingletonServices,
|
|
@@ -165,11 +170,25 @@ export class PgBossQueueWorkers implements QueueWorkers {
|
|
|
165
170
|
)
|
|
166
171
|
return
|
|
167
172
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
+
try {
|
|
174
|
+
await runQueueJob({
|
|
175
|
+
singletonServices: this.singletonServices,
|
|
176
|
+
createSessionServices: this.createSessionServices,
|
|
177
|
+
job: mapPgBossJobToQueueJob(job, this.pgBoss),
|
|
178
|
+
})
|
|
179
|
+
} catch (error: unknown) {
|
|
180
|
+
if (error instanceof QueueJobFailedError) {
|
|
181
|
+
// Let pg-boss handle this as a failed job
|
|
182
|
+
throw new Error(error.message)
|
|
183
|
+
} else if (error instanceof QueueJobDiscardedError) {
|
|
184
|
+
// For pg-boss, complete the job successfully to discard it
|
|
185
|
+
this.singletonServices.logger.info(
|
|
186
|
+
`PgBoss job ${job.id} discarded: ${error.message}`
|
|
187
|
+
)
|
|
188
|
+
return // Successfully "completed" by discarding
|
|
189
|
+
}
|
|
190
|
+
throw error
|
|
191
|
+
}
|
|
173
192
|
}
|
|
174
193
|
)
|
|
175
194
|
this.activeWorkers.set(queueName, workerId)
|