@workflow/world-postgres 4.1.0-beta.15 → 4.1.0-beta.16
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/dist/queue.d.ts +2 -2
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +11 -7
- package/dist/queue.js.map +1 -1
- package/package.json +6 -6
package/dist/queue.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ import type { PostgresWorldConfig } from './config.js';
|
|
|
7
7
|
* - `step` for step jobs
|
|
8
8
|
*
|
|
9
9
|
* When a message is queued, it is sent to pg-boss with the appropriate job type.
|
|
10
|
-
* When a job is processed, it is deserialized and then re-queued into the
|
|
11
|
-
* we can reuse the
|
|
10
|
+
* When a job is processed, it is deserialized and then re-queued into the _local world_, showing that
|
|
11
|
+
* we can reuse the local world, mix and match worlds to build
|
|
12
12
|
* hybrid architectures, and even migrate between worlds.
|
|
13
13
|
*/
|
|
14
14
|
export declare function createQueue(boss: PgBoss, config: PostgresWorldConfig): Queue & {
|
package/dist/queue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,KAAK,EAIX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,MAAM,MAAM,SAAS,CAAC;AAGlC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,mBAAmB,GAC1B,KAAK,GAAG;IAAE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,KAAK,EAIX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,MAAM,MAAM,SAAS,CAAC;AAGlC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,mBAAmB,GAC1B,KAAK,GAAG;IAAE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAwGpC"}
|
package/dist/queue.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Stream from 'node:stream';
|
|
2
2
|
import { JsonTransport } from '@vercel/queue';
|
|
3
3
|
import { MessageId, QueuePayloadSchema, } from '@workflow/world';
|
|
4
|
-
import {
|
|
4
|
+
import { createLocalWorld } from '@workflow/world-local';
|
|
5
5
|
import { monotonicFactory } from 'ulid';
|
|
6
6
|
import { MessageData } from './boss.js';
|
|
7
7
|
/**
|
|
@@ -10,13 +10,13 @@ import { MessageData } from './boss.js';
|
|
|
10
10
|
* - `step` for step jobs
|
|
11
11
|
*
|
|
12
12
|
* When a message is queued, it is sent to pg-boss with the appropriate job type.
|
|
13
|
-
* When a job is processed, it is deserialized and then re-queued into the
|
|
14
|
-
* we can reuse the
|
|
13
|
+
* When a job is processed, it is deserialized and then re-queued into the _local world_, showing that
|
|
14
|
+
* we can reuse the local world, mix and match worlds to build
|
|
15
15
|
* hybrid architectures, and even migrate between worlds.
|
|
16
16
|
*/
|
|
17
17
|
export function createQueue(boss, config) {
|
|
18
18
|
const port = process.env.PORT ? Number(process.env.PORT) : undefined;
|
|
19
|
-
const
|
|
19
|
+
const localWorld = createLocalWorld({ dataDir: undefined, port });
|
|
20
20
|
const transport = new JsonTransport();
|
|
21
21
|
const generateMessageId = monotonicFactory();
|
|
22
22
|
const prefix = config.jobPrefix || 'workflow_';
|
|
@@ -24,7 +24,7 @@ export function createQueue(boss, config) {
|
|
|
24
24
|
__wkf_workflow_: `${prefix}flows`,
|
|
25
25
|
__wkf_step_: `${prefix}steps`,
|
|
26
26
|
};
|
|
27
|
-
const createQueueHandler =
|
|
27
|
+
const createQueueHandler = localWorld.createQueueHandler;
|
|
28
28
|
const getDeploymentId = async () => {
|
|
29
29
|
return 'postgres';
|
|
30
30
|
};
|
|
@@ -63,7 +63,11 @@ export function createQueue(boss, config) {
|
|
|
63
63
|
async function setupListener(queue, jobName) {
|
|
64
64
|
await createQueue(jobName);
|
|
65
65
|
await Promise.all(Array.from({ length: config.queueConcurrency || 10 }, async () => {
|
|
66
|
-
await boss.work(jobName,
|
|
66
|
+
await boss.work(jobName, {
|
|
67
|
+
// The default is 2s, which is far too slow for running steps in quick succession.
|
|
68
|
+
// The min is 0.5s, which is still too slow. We should move to a pg NOTIFY/LISTEN-based job system.
|
|
69
|
+
pollingIntervalSeconds: 0.5,
|
|
70
|
+
}, work);
|
|
67
71
|
}));
|
|
68
72
|
async function work([job]) {
|
|
69
73
|
const messageData = MessageData.parse(job.data);
|
|
@@ -71,7 +75,7 @@ export function createQueue(boss, config) {
|
|
|
71
75
|
const body = await transport.deserialize(bodyStream);
|
|
72
76
|
const message = QueuePayloadSchema.parse(body);
|
|
73
77
|
const queueName = `${queue}${messageData.id}`;
|
|
74
|
-
await
|
|
78
|
+
await localWorld.queue(queueName, message, {
|
|
75
79
|
idempotencyKey: messageData.idempotencyKey,
|
|
76
80
|
});
|
|
77
81
|
}
|
package/dist/queue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,SAAS,EAET,kBAAkB,GAGnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,a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,aAAa,EAAE,iBAAiB,CAAC,CAAC;IACnE,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC9B,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;AACjD,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workflow/world-postgres",
|
|
3
|
-
"version": "4.1.0-beta.
|
|
3
|
+
"version": "4.1.0-beta.16",
|
|
4
4
|
"description": "A reference World implementation based on PostgreSQL",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -45,18 +45,18 @@
|
|
|
45
45
|
"postgres": "3.4.7",
|
|
46
46
|
"ulid": "3.0.1",
|
|
47
47
|
"zod": "4.1.11",
|
|
48
|
-
"@workflow/
|
|
49
|
-
"@workflow/world": "4.0.1-beta.
|
|
50
|
-
"@workflow/
|
|
48
|
+
"@workflow/world": "4.0.1-beta.8",
|
|
49
|
+
"@workflow/world-local": "4.0.1-beta.14",
|
|
50
|
+
"@workflow/errors": "4.0.1-beta.7"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@testcontainers/postgresql": "11.7.1",
|
|
54
54
|
"@types/node": "22.19.0",
|
|
55
55
|
"drizzle-kit": "0.31.6",
|
|
56
56
|
"vitest": "^3.2.4",
|
|
57
|
+
"@workflow/errors": "4.0.1-beta.7",
|
|
57
58
|
"@workflow/tsconfig": "4.0.1-beta.0",
|
|
58
|
-
"@workflow/world-testing": "4.0.1-beta.
|
|
59
|
-
"@workflow/errors": "4.0.1-beta.6"
|
|
59
|
+
"@workflow/world-testing": "4.0.1-beta.24"
|
|
60
60
|
},
|
|
61
61
|
"keywords": [],
|
|
62
62
|
"author": "",
|