@pikku/queue-pg-boss 0.12.8 → 0.12.9
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 +14 -0
- package/LICENSE +21 -0
- package/README.md +29 -0
- package/dist/index.d.ts +2 -1
- package/dist/pg-boss-queue-service.d.ts +2 -1
- package/dist/pg-boss-queue-service.js +3 -1
- package/dist/pg-boss-queue-worker.d.ts +1 -1
- package/dist/pg-boss-queue-worker.js +3 -2
- package/dist/pg-boss-scheduler-service.d.ts +2 -1
- package/dist/pg-boss-scheduler-service.js +5 -3
- package/package.json +3 -2
- package/src/index.ts +2 -3
- package/src/pg-boss-queue-service.ts +5 -2
- package/src/pg-boss-queue-worker.ts +4 -4
- package/src/pg-boss-scheduler-service.ts +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## 0.12.9
|
|
2
|
+
|
|
3
|
+
### Patch Changes
|
|
4
|
+
|
|
5
|
+
- 6794681: Publish the ecosystem surface as per-area sub-barrels under `@pikku/core/ecosystem/*`, and point generated code, the CLI, the inspector and the runtime adapters at them.
|
|
6
|
+
|
|
7
|
+
348 names that only generated code, the toolchain or a runtime adapter ever imports now have a second home on `@pikku/core/ecosystem/<area>` — one sub-barrel per area, matching how core already publishes its entrypoints, so no single barrel grows without bound and a consumer only pulls in the area it uses.
|
|
8
|
+
|
|
9
|
+
This step is additive: every name is still exported from the entrypoint it was published from before, so nothing downstream breaks. Removing them from the app-facing barrels is a later change, and needs a release carrying `./ecosystem/*` first.
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [7406bfe]
|
|
12
|
+
- Updated dependencies [6794681]
|
|
13
|
+
- @pikku/core@0.12.84
|
|
14
|
+
|
|
1
15
|
## 0.12.8
|
|
2
16
|
|
|
3
17
|
### Patch Changes
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 - present Yasser Fadl and Pikku contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @pikku/queue-pg-boss
|
|
2
|
+
|
|
3
|
+
pg-boss queue, worker and scheduler services for Pikku. Backed by Postgres, so
|
|
4
|
+
it needs no extra infrastructure if you already run one.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install @pikku/queue-pg-boss
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import PgBoss from 'pg-boss'
|
|
16
|
+
import { PgBossQueueService } from '@pikku/queue-pg-boss'
|
|
17
|
+
|
|
18
|
+
const pgBoss = new PgBoss(connectionString)
|
|
19
|
+
await pgBoss.start()
|
|
20
|
+
|
|
21
|
+
const queue = new PgBossQueueService(pgBoss)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Use `PgBossQueueWorkers` to process jobs and `PgBossSchedulerService` for cron
|
|
25
|
+
wirings. For a Redis-backed alternative see `@pikku/queue-bullmq`.
|
|
26
|
+
|
|
27
|
+
## Docs
|
|
28
|
+
|
|
29
|
+
https://pikku.dev/docs
|
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,5 @@ export { PgBossServiceFactory } from './pg-boss-service-factory.js';
|
|
|
8
8
|
export { PgBossQueueService } from './pg-boss-queue-service.js';
|
|
9
9
|
export { PgBossQueueWorkers } from './pg-boss-queue-worker.js';
|
|
10
10
|
export { PgBossSchedulerService } from './pg-boss-scheduler-service.js';
|
|
11
|
-
export type { QueueService,
|
|
11
|
+
export type { QueueService, QueueJob } from '@pikku/core/queue';
|
|
12
|
+
export type { PikkuWorkerConfig, PikkuJobConfig, JobOptions, } from '@pikku/core/ecosystem/queue';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PgBoss, Request as PgBossRequest } from 'pg-boss';
|
|
2
|
-
import type { QueueService, QueueJob
|
|
2
|
+
import type { QueueService, QueueJob } from '@pikku/core/queue';
|
|
3
|
+
import type { JobOptions } from '@pikku/core/ecosystem/queue';
|
|
3
4
|
export declare const mapPikkuJobToPgBoss: (options?: JobOptions) => PgBossRequest["options"];
|
|
4
5
|
/**
|
|
5
6
|
* pg-boss/PostgreSQL queue service implementation
|
|
@@ -21,7 +21,9 @@ export const mapPikkuJobToPgBoss = (options) => {
|
|
|
21
21
|
pgBossOptions.retryLimit = options.attempts - 1;
|
|
22
22
|
}
|
|
23
23
|
if (options?.backoff !== undefined) {
|
|
24
|
-
const type = typeof options.backoff === 'string'
|
|
24
|
+
const type = typeof options.backoff === 'string'
|
|
25
|
+
? options.backoff
|
|
26
|
+
: options.backoff.type;
|
|
25
27
|
const delay = typeof options.backoff === 'object' ? options.backoff.delay : undefined;
|
|
26
28
|
pgBossOptions.retryBackoff = type === 'exponential';
|
|
27
29
|
if (delay !== undefined) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PgBoss, WorkOptions } from 'pg-boss';
|
|
2
|
-
import type { QueueWorkers, PikkuWorkerConfig, QueueConfigMapping, ConfigValidationResult } from '@pikku/core/queue';
|
|
2
|
+
import type { QueueWorkers, PikkuWorkerConfig, QueueConfigMapping, ConfigValidationResult } from '@pikku/core/ecosystem/queue';
|
|
3
3
|
import type { Logger } from '@pikku/core/services';
|
|
4
4
|
export declare const mapPikkuWorkerToPgBoss: (workerConfig?: PikkuWorkerConfig) => WorkOptions;
|
|
5
5
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { runQueueJob } from '@pikku/core/queue';
|
|
2
|
+
import { registerQueueWorkers, QueueJobFailedError, QueueJobDiscardedError, } from '@pikku/core/ecosystem/queue';
|
|
3
|
+
import { pikkuState } from '@pikku/core/ecosystem';
|
|
3
4
|
import { mapPgBossJobToQueueJob } from './utils.js';
|
|
4
5
|
export const mapPikkuWorkerToPgBoss = (workerConfig) => {
|
|
5
6
|
// Map the requested parallelism to pg-boss `localConcurrency` (independent
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PgBoss } from 'pg-boss';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CoreUserSession } from '@pikku/core';
|
|
3
|
+
import type { ScheduledTaskInfo, ScheduledTaskSummary } from '@pikku/core/ecosystem/services';
|
|
3
4
|
import { SchedulerService } from '@pikku/core';
|
|
4
5
|
/**
|
|
5
6
|
* pg-boss scheduler service implementation
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { SchedulerService
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { SchedulerService } from '@pikku/core';
|
|
2
|
+
import { parseDurationString } from '@pikku/core/ecosystem/types';
|
|
3
|
+
import { pikkuState } from '@pikku/core/ecosystem';
|
|
4
|
+
import { runScheduledTask } from '@pikku/core/scheduler';
|
|
5
|
+
import { getScheduledTasks } from '@pikku/core/ecosystem/scheduler';
|
|
4
6
|
/** Prefix for pg-boss queues/schedules backing recurring scheduled tasks. */
|
|
5
7
|
const RECURRING_TASK_PREFIX = 'pikku-recurring-scheduled-task_';
|
|
6
8
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/queue-pg-boss",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.9",
|
|
4
|
+
"description": "pg-boss queue, worker and scheduler services for Pikku, backed by Postgres",
|
|
4
5
|
"author": "yasser.fadl@gmail.com",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"module": "dist/index.js",
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
"prepublishOnly": "yarn build"
|
|
16
17
|
},
|
|
17
18
|
"peerDependencies": {
|
|
18
|
-
"@pikku/core": "^0.12.
|
|
19
|
+
"@pikku/core": "^0.12.84"
|
|
19
20
|
},
|
|
20
21
|
"dependencies": {
|
|
21
22
|
"pg-boss": "^12.14.0"
|
package/src/index.ts
CHANGED
|
@@ -11,10 +11,9 @@ export { PgBossQueueWorkers } from './pg-boss-queue-worker.js'
|
|
|
11
11
|
export { PgBossSchedulerService } from './pg-boss-scheduler-service.js'
|
|
12
12
|
|
|
13
13
|
// Re-export core queue types for convenience
|
|
14
|
+
export type { QueueService, QueueJob } from '@pikku/core/queue'
|
|
14
15
|
export type {
|
|
15
|
-
QueueService,
|
|
16
16
|
PikkuWorkerConfig,
|
|
17
17
|
PikkuJobConfig,
|
|
18
|
-
QueueJob,
|
|
19
18
|
JobOptions,
|
|
20
|
-
} from '@pikku/core/queue'
|
|
19
|
+
} from '@pikku/core/ecosystem/queue'
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PgBoss, Request as PgBossRequest } from 'pg-boss'
|
|
2
|
-
import type { QueueService, QueueJob
|
|
2
|
+
import type { QueueService, QueueJob } from '@pikku/core/queue'
|
|
3
|
+
import type { JobOptions } from '@pikku/core/ecosystem/queue'
|
|
3
4
|
import { mapPgBossJobToQueueJob } from './utils.js'
|
|
4
5
|
|
|
5
6
|
export const mapPikkuJobToPgBoss = (
|
|
@@ -33,7 +34,9 @@ export const mapPikkuJobToPgBoss = (
|
|
|
33
34
|
|
|
34
35
|
if (options?.backoff !== undefined) {
|
|
35
36
|
const type =
|
|
36
|
-
typeof options.backoff === 'string'
|
|
37
|
+
typeof options.backoff === 'string'
|
|
38
|
+
? options.backoff
|
|
39
|
+
: options.backoff.type
|
|
37
40
|
const delay =
|
|
38
41
|
typeof options.backoff === 'object' ? options.backoff.delay : undefined
|
|
39
42
|
pgBossOptions.retryBackoff = type === 'exponential'
|
|
@@ -4,14 +4,14 @@ import type {
|
|
|
4
4
|
PikkuWorkerConfig,
|
|
5
5
|
QueueConfigMapping,
|
|
6
6
|
ConfigValidationResult,
|
|
7
|
-
} from '@pikku/core/queue'
|
|
7
|
+
} from '@pikku/core/ecosystem/queue'
|
|
8
|
+
import { runQueueJob } from '@pikku/core/queue'
|
|
8
9
|
import {
|
|
9
10
|
registerQueueWorkers,
|
|
10
|
-
runQueueJob,
|
|
11
11
|
QueueJobFailedError,
|
|
12
12
|
QueueJobDiscardedError,
|
|
13
|
-
} from '@pikku/core/queue'
|
|
14
|
-
import { pikkuState } from '@pikku/core/
|
|
13
|
+
} from '@pikku/core/ecosystem/queue'
|
|
14
|
+
import { pikkuState } from '@pikku/core/ecosystem'
|
|
15
15
|
import type { Logger } from '@pikku/core/services'
|
|
16
16
|
import { mapPgBossJobToQueueJob } from './utils.js'
|
|
17
17
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { PgBoss } from 'pg-boss'
|
|
2
|
+
import type { CoreUserSession } from '@pikku/core'
|
|
2
3
|
import type {
|
|
3
4
|
ScheduledTaskInfo,
|
|
4
5
|
ScheduledTaskSummary,
|
|
5
|
-
|
|
6
|
-
} from '@pikku/core'
|
|
7
|
-
import {
|
|
8
|
-
import { pikkuState } from '@pikku/core/
|
|
9
|
-
import { runScheduledTask
|
|
6
|
+
} from '@pikku/core/ecosystem/services'
|
|
7
|
+
import { SchedulerService } from '@pikku/core'
|
|
8
|
+
import { parseDurationString } from '@pikku/core/ecosystem/types'
|
|
9
|
+
import { pikkuState } from '@pikku/core/ecosystem'
|
|
10
|
+
import { runScheduledTask } from '@pikku/core/scheduler'
|
|
11
|
+
import { getScheduledTasks } from '@pikku/core/ecosystem/scheduler'
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Data stored in scheduled job
|