@pikku/queue-pg-boss 0.11.0 → 0.11.1
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 -1
- package/dist/pg-boss-queue-service.d.ts +2 -2
- package/dist/pg-boss-queue-worker.d.ts +5 -5
- package/dist/pg-boss-queue-worker.js +4 -4
- package/dist/pg-boss-scheduler-service.d.ts +1 -1
- package/dist/pg-boss-service-factory.d.ts +4 -4
- package/dist/pg-boss-service-factory.js +3 -3
- package/dist/utils.d.ts +2 -2
- package/package.json +3 -3
- package/src/pg-boss-queue-service.ts +3 -3
- package/src/pg-boss-queue-worker.ts +6 -6
- package/src/pg-boss-scheduler-service.ts +1 -1
- package/src/pg-boss-service-factory.ts +5 -5
- package/src/utils.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
## 0.11.0
|
|
2
2
|
|
|
3
|
+
## 0.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4b811db: chore: updating all dependencies
|
|
8
|
+
- 06e1a31: breaking: change session services to wire services
|
|
9
|
+
- Updated dependencies [4b811db]
|
|
10
|
+
- Updated dependencies [e12a00c]
|
|
11
|
+
- Updated dependencies [4579434]
|
|
12
|
+
- Updated dependencies [28aeb7f]
|
|
13
|
+
- Updated dependencies [ce902b1]
|
|
14
|
+
- Updated dependencies [06e1a31]
|
|
15
|
+
- @pikku/core@0.11.1
|
|
16
|
+
|
|
3
17
|
### Minor Changes
|
|
4
18
|
|
|
5
19
|
- Add scheduler service implementation
|
|
6
20
|
- Add service factory for queue and scheduler creation
|
|
7
21
|
|
|
8
|
-
|
|
9
22
|
# @pikku/queue-pg-boss
|
|
10
23
|
|
|
11
24
|
## 0.10.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import PgBoss from 'pg-boss';
|
|
1
|
+
import { PgBoss, Request as PgBossRequest } from 'pg-boss';
|
|
2
2
|
import type { QueueService, QueueJob, JobOptions } from '@pikku/core/queue';
|
|
3
|
-
export declare const mapPikkuJobToPgBoss: (options?: JobOptions) =>
|
|
3
|
+
export declare const mapPikkuJobToPgBoss: (options?: JobOptions) => PgBossRequest["options"];
|
|
4
4
|
/**
|
|
5
5
|
* pg-boss/PostgreSQL queue service implementation
|
|
6
6
|
* Supports job results, retries, and PostgreSQL-based queuing
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import PgBoss from 'pg-boss';
|
|
1
|
+
import { PgBoss, type WorkOptions } from 'pg-boss';
|
|
2
2
|
import type { QueueWorkers, PikkuWorkerConfig, QueueConfigMapping, ConfigValidationResult } from '@pikku/core/queue';
|
|
3
|
-
import { CoreServices, CoreSingletonServices,
|
|
4
|
-
export declare const mapPikkuWorkerToPgBoss: (workerConfig?: PikkuWorkerConfig) =>
|
|
3
|
+
import { CoreServices, CoreSingletonServices, CreateWireServices } from '@pikku/core';
|
|
4
|
+
export declare const mapPikkuWorkerToPgBoss: (workerConfig?: PikkuWorkerConfig) => WorkOptions;
|
|
5
5
|
/**
|
|
6
6
|
* pg-boss/PostgreSQL queue worker implementation
|
|
7
7
|
* Supports job results, retries, and PostgreSQL-based queuing
|
|
8
8
|
*/
|
|
9
9
|
export declare class PgBossQueueWorkers implements QueueWorkers {
|
|
10
10
|
private singletonServices;
|
|
11
|
-
private
|
|
11
|
+
private createWireServices?;
|
|
12
12
|
readonly name = "pg-boss";
|
|
13
13
|
readonly supportsResults = true;
|
|
14
14
|
/**
|
|
@@ -18,7 +18,7 @@ export declare class PgBossQueueWorkers implements QueueWorkers {
|
|
|
18
18
|
readonly configMappings: QueueConfigMapping;
|
|
19
19
|
private pgBoss;
|
|
20
20
|
private activeWorkers;
|
|
21
|
-
constructor(pgBoss: PgBoss, singletonServices: CoreSingletonServices,
|
|
21
|
+
constructor(pgBoss: PgBoss, singletonServices: CoreSingletonServices, createWireServices?: CreateWireServices<CoreSingletonServices, CoreServices, any> | undefined);
|
|
22
22
|
/**
|
|
23
23
|
* Scan state and register all compatible processors
|
|
24
24
|
*/
|
|
@@ -16,7 +16,7 @@ export const mapPikkuWorkerToPgBoss = (workerConfig) => {
|
|
|
16
16
|
*/
|
|
17
17
|
export class PgBossQueueWorkers {
|
|
18
18
|
singletonServices;
|
|
19
|
-
|
|
19
|
+
createWireServices;
|
|
20
20
|
name = 'pg-boss';
|
|
21
21
|
supportsResults = true;
|
|
22
22
|
/**
|
|
@@ -83,9 +83,9 @@ export class PgBossQueueWorkers {
|
|
|
83
83
|
};
|
|
84
84
|
pgBoss;
|
|
85
85
|
activeWorkers = new Map();
|
|
86
|
-
constructor(pgBoss, singletonServices,
|
|
86
|
+
constructor(pgBoss, singletonServices, createWireServices) {
|
|
87
87
|
this.singletonServices = singletonServices;
|
|
88
|
-
this.
|
|
88
|
+
this.createWireServices = createWireServices;
|
|
89
89
|
this.pgBoss = pgBoss;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
@@ -108,7 +108,7 @@ export class PgBossQueueWorkers {
|
|
|
108
108
|
try {
|
|
109
109
|
await runQueueJob({
|
|
110
110
|
singletonServices: this.singletonServices,
|
|
111
|
-
|
|
111
|
+
createWireServices: this.createWireServices,
|
|
112
112
|
job: mapPgBossJobToQueueJob(job, this.pgBoss),
|
|
113
113
|
});
|
|
114
114
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import PgBoss from 'pg-boss';
|
|
1
|
+
import { PgBoss, type ConstructorOptions } from 'pg-boss';
|
|
2
2
|
import { PgBossQueueService } from './pg-boss-queue-service.js';
|
|
3
3
|
import { PgBossQueueWorkers } from './pg-boss-queue-worker.js';
|
|
4
4
|
import { PgBossSchedulerService } from './pg-boss-scheduler-service.js';
|
|
5
|
-
import type { CoreServices, CoreSingletonServices,
|
|
5
|
+
import type { CoreServices, CoreSingletonServices, CreateWireServices } from '@pikku/core';
|
|
6
6
|
/**
|
|
7
7
|
* Factory class for pg-boss services
|
|
8
8
|
* Manages a single PgBoss instance shared across queue, worker, and scheduler services
|
|
@@ -13,7 +13,7 @@ export declare class PgBossServiceFactory {
|
|
|
13
13
|
private queueWorkers?;
|
|
14
14
|
private schedulerService?;
|
|
15
15
|
private initialized;
|
|
16
|
-
constructor(optionsOrInstance:
|
|
16
|
+
constructor(optionsOrInstance: ConstructorOptions | string | PgBoss);
|
|
17
17
|
/**
|
|
18
18
|
* Initialize the pg-boss instance
|
|
19
19
|
*/
|
|
@@ -25,7 +25,7 @@ export declare class PgBossServiceFactory {
|
|
|
25
25
|
/**
|
|
26
26
|
* Get the queue workers for processing jobs
|
|
27
27
|
*/
|
|
28
|
-
getQueueWorkers(singletonServices: CoreSingletonServices,
|
|
28
|
+
getQueueWorkers(singletonServices: CoreSingletonServices, createWireServices?: CreateWireServices<CoreSingletonServices, CoreServices, any>): PgBossQueueWorkers;
|
|
29
29
|
/**
|
|
30
30
|
* Get the scheduler service for managing recurring tasks
|
|
31
31
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import PgBoss from 'pg-boss';
|
|
1
|
+
import { PgBoss } from 'pg-boss';
|
|
2
2
|
import { PgBossQueueService } from './pg-boss-queue-service.js';
|
|
3
3
|
import { PgBossQueueWorkers } from './pg-boss-queue-worker.js';
|
|
4
4
|
import { PgBossSchedulerService } from './pg-boss-scheduler-service.js';
|
|
@@ -44,9 +44,9 @@ export class PgBossServiceFactory {
|
|
|
44
44
|
/**
|
|
45
45
|
* Get the queue workers for processing jobs
|
|
46
46
|
*/
|
|
47
|
-
getQueueWorkers(singletonServices,
|
|
47
|
+
getQueueWorkers(singletonServices, createWireServices) {
|
|
48
48
|
if (!this.queueWorkers) {
|
|
49
|
-
this.queueWorkers = new PgBossQueueWorkers(this.pgBoss, singletonServices,
|
|
49
|
+
this.queueWorkers = new PgBossQueueWorkers(this.pgBoss, singletonServices, createWireServices);
|
|
50
50
|
}
|
|
51
51
|
return this.queueWorkers;
|
|
52
52
|
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QueueJob } from '@pikku/core/queue';
|
|
2
|
-
import PgBoss from 'pg-boss';
|
|
2
|
+
import { PgBoss, type JobWithMetadata } from 'pg-boss';
|
|
3
3
|
/**
|
|
4
4
|
* Map pg-boss job to QueueJob interface
|
|
5
5
|
*/
|
|
6
|
-
export declare const mapPgBossJobToQueueJob: <In, Out>(pgBossJob:
|
|
6
|
+
export declare const mapPgBossJobToQueueJob: <In, Out>(pgBossJob: JobWithMetadata<In>, pgBossInstance: PgBoss) => QueueJob<In, Out>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/queue-pg-boss",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"author": "yasser.fadl@gmail.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"release": "npm run build && npm test"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"@pikku/core": "^0.11.
|
|
16
|
+
"@pikku/core": "^0.11.1"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"pg-boss": "^
|
|
19
|
+
"pg-boss": "^12.2.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"typescript": "^5.9"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import PgBoss from 'pg-boss'
|
|
1
|
+
import { PgBoss, Request as PgBossRequest } from 'pg-boss'
|
|
2
2
|
import type { QueueService, QueueJob, JobOptions } from '@pikku/core/queue'
|
|
3
3
|
import { mapPgBossJobToQueueJob } from './utils.js'
|
|
4
4
|
|
|
5
5
|
export const mapPikkuJobToPgBoss = (
|
|
6
6
|
options?: JobOptions
|
|
7
|
-
):
|
|
7
|
+
): PgBossRequest['options'] => {
|
|
8
8
|
const pgBossOptions: any = {}
|
|
9
9
|
|
|
10
10
|
if (options?.priority !== undefined) {
|
|
@@ -46,7 +46,7 @@ export const mapPikkuJobToPgBoss = (
|
|
|
46
46
|
// Note: pg-boss keeps failed jobs by default
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
return pgBossOptions as
|
|
49
|
+
return pgBossOptions as PgBossRequest['options']
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import PgBoss from 'pg-boss'
|
|
1
|
+
import { PgBoss, type WorkOptions } from 'pg-boss'
|
|
2
2
|
import type {
|
|
3
3
|
QueueWorkers,
|
|
4
4
|
PikkuWorkerConfig,
|
|
@@ -14,14 +14,14 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
CoreServices,
|
|
16
16
|
CoreSingletonServices,
|
|
17
|
-
|
|
17
|
+
CreateWireServices,
|
|
18
18
|
} from '@pikku/core'
|
|
19
19
|
import { mapPgBossJobToQueueJob } from './utils.js'
|
|
20
20
|
|
|
21
21
|
export const mapPikkuWorkerToPgBoss = (
|
|
22
22
|
workerConfig?: PikkuWorkerConfig
|
|
23
|
-
):
|
|
24
|
-
const workerOptions:
|
|
23
|
+
): WorkOptions => {
|
|
24
|
+
const workerOptions: WorkOptions = {}
|
|
25
25
|
|
|
26
26
|
if (workerConfig?.batchSize !== undefined) {
|
|
27
27
|
workerOptions.batchSize = workerConfig.batchSize
|
|
@@ -125,7 +125,7 @@ export class PgBossQueueWorkers implements QueueWorkers {
|
|
|
125
125
|
constructor(
|
|
126
126
|
pgBoss: PgBoss,
|
|
127
127
|
private singletonServices: CoreSingletonServices,
|
|
128
|
-
private
|
|
128
|
+
private createWireServices?: CreateWireServices<
|
|
129
129
|
CoreSingletonServices,
|
|
130
130
|
CoreServices,
|
|
131
131
|
any
|
|
@@ -162,7 +162,7 @@ export class PgBossQueueWorkers implements QueueWorkers {
|
|
|
162
162
|
try {
|
|
163
163
|
await runQueueJob({
|
|
164
164
|
singletonServices: this.singletonServices,
|
|
165
|
-
|
|
165
|
+
createWireServices: this.createWireServices,
|
|
166
166
|
job: mapPgBossJobToQueueJob(job, this.pgBoss),
|
|
167
167
|
})
|
|
168
168
|
} catch (error: unknown) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import PgBoss from 'pg-boss'
|
|
1
|
+
import { PgBoss, type ConstructorOptions } from 'pg-boss'
|
|
2
2
|
import { PgBossQueueService } from './pg-boss-queue-service.js'
|
|
3
3
|
import { PgBossQueueWorkers } from './pg-boss-queue-worker.js'
|
|
4
4
|
import { PgBossSchedulerService } from './pg-boss-scheduler-service.js'
|
|
5
5
|
import type {
|
|
6
6
|
CoreServices,
|
|
7
7
|
CoreSingletonServices,
|
|
8
|
-
|
|
8
|
+
CreateWireServices,
|
|
9
9
|
} from '@pikku/core'
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -19,7 +19,7 @@ export class PgBossServiceFactory {
|
|
|
19
19
|
private schedulerService?: PgBossSchedulerService
|
|
20
20
|
private initialized = false
|
|
21
21
|
|
|
22
|
-
constructor(optionsOrInstance:
|
|
22
|
+
constructor(optionsOrInstance: ConstructorOptions | string | PgBoss) {
|
|
23
23
|
if (optionsOrInstance instanceof PgBoss) {
|
|
24
24
|
this.pgBoss = optionsOrInstance
|
|
25
25
|
} else {
|
|
@@ -56,7 +56,7 @@ export class PgBossServiceFactory {
|
|
|
56
56
|
*/
|
|
57
57
|
getQueueWorkers(
|
|
58
58
|
singletonServices: CoreSingletonServices,
|
|
59
|
-
|
|
59
|
+
createWireServices?: CreateWireServices<
|
|
60
60
|
CoreSingletonServices,
|
|
61
61
|
CoreServices,
|
|
62
62
|
any
|
|
@@ -66,7 +66,7 @@ export class PgBossServiceFactory {
|
|
|
66
66
|
this.queueWorkers = new PgBossQueueWorkers(
|
|
67
67
|
this.pgBoss,
|
|
68
68
|
singletonServices,
|
|
69
|
-
|
|
69
|
+
createWireServices
|
|
70
70
|
)
|
|
71
71
|
}
|
|
72
72
|
return this.queueWorkers
|
package/src/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueueJob, QueueJobStatus } from '@pikku/core/queue'
|
|
2
|
-
import PgBoss from 'pg-boss'
|
|
2
|
+
import { PgBoss, type JobWithMetadata } from 'pg-boss'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Map pg-boss job state to our queue job status
|
|
@@ -26,7 +26,7 @@ const mapPgBossStateToStatus = (state: string): QueueJobStatus => {
|
|
|
26
26
|
* Map pg-boss job to QueueJob interface
|
|
27
27
|
*/
|
|
28
28
|
export const mapPgBossJobToQueueJob = <In, Out>(
|
|
29
|
-
pgBossJob:
|
|
29
|
+
pgBossJob: JobWithMetadata<In>,
|
|
30
30
|
pgBossInstance: PgBoss
|
|
31
31
|
): QueueJob<In, Out> => {
|
|
32
32
|
return {
|