@geekmidas/events 10.0.0-alpha.9 → 10.0.0-alpha.91
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 +46 -1
- package/dist/SQSSubscriber-BEJBfNTe.mjs +264 -0
- package/dist/SQSSubscriber-BEJBfNTe.mjs.map +1 -0
- package/dist/SQSSubscriber-COTqWvOk.cjs +288 -0
- package/dist/SQSSubscriber-COTqWvOk.cjs.map +1 -0
- package/dist/basic/index.cjs +41 -11
- package/dist/basic/index.cjs.map +1 -1
- package/dist/basic/index.d.cts +11 -10
- package/dist/basic/index.d.cts.map +1 -1
- package/dist/basic/index.d.mts +11 -10
- package/dist/basic/index.d.mts.map +1 -1
- package/dist/basic/index.mjs +39 -10
- package/dist/basic/index.mjs.map +1 -1
- package/dist/index.cjs +47 -151
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -26
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +82 -26
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +34 -151
- package/dist/index.mjs.map +1 -1
- package/dist/pgboss/index.cjs +198 -34
- package/dist/pgboss/index.cjs.map +1 -1
- package/dist/pgboss/index.d.cts +54 -12
- package/dist/pgboss/index.d.cts.map +1 -1
- package/dist/pgboss/index.d.mts +54 -12
- package/dist/pgboss/index.d.mts.map +1 -1
- package/dist/pgboss/index.mjs +193 -34
- package/dist/pgboss/index.mjs.map +1 -1
- package/dist/rabbitmq/index.cjs +173 -27
- package/dist/rabbitmq/index.cjs.map +1 -1
- package/dist/rabbitmq/index.d.cts +19 -10
- package/dist/rabbitmq/index.d.cts.map +1 -1
- package/dist/rabbitmq/index.d.mts +19 -10
- package/dist/rabbitmq/index.d.mts.map +1 -1
- package/dist/rabbitmq/index.mjs +169 -27
- package/dist/rabbitmq/index.mjs.map +1 -1
- package/dist/registry-DIx25Q5s.d.cts +255 -0
- package/dist/registry-DIx25Q5s.d.cts.map +1 -0
- package/dist/registry-DIx25Q5s.d.mts +255 -0
- package/dist/registry-DIx25Q5s.d.mts.map +1 -0
- package/dist/registry-DXLY1Xf6.mjs +99 -0
- package/dist/registry-DXLY1Xf6.mjs.map +1 -0
- package/dist/registry-DlT36229.cjs +122 -0
- package/dist/registry-DlT36229.cjs.map +1 -0
- package/dist/{chunk-CsX-DzYB.cjs → rolldown-runtime-C0BPl7ul.cjs} +17 -16
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/sns/index.cjs +403 -40
- package/dist/sns/index.cjs.map +1 -1
- package/dist/sns/index.d.cts +175 -11
- package/dist/sns/index.d.cts.map +1 -1
- package/dist/sns/index.d.mts +175 -11
- package/dist/sns/index.d.mts.map +1 -1
- package/dist/sns/index.mjs +372 -24
- package/dist/sns/index.mjs.map +1 -1
- package/dist/sns/snsUrl.cjs +91 -6
- package/dist/sns/snsUrl.cjs.map +1 -0
- package/dist/sns/snsUrl.d.cts +57 -2
- package/dist/sns/snsUrl.d.cts.map +1 -0
- package/dist/sns/snsUrl.d.mts +57 -2
- package/dist/sns/snsUrl.d.mts.map +1 -0
- package/dist/sns/snsUrl.mjs +81 -2
- package/dist/sns/snsUrl.mjs.map +1 -0
- package/dist/sqs/index.cjs +31 -65
- package/dist/sqs/index.cjs.map +1 -1
- package/dist/sqs/index.d.cts +28 -11
- package/dist/sqs/index.d.cts.map +1 -1
- package/dist/sqs/index.d.mts +28 -11
- package/dist/sqs/index.d.mts.map +1 -1
- package/dist/sqs/index.mjs +22 -58
- package/dist/sqs/index.mjs.map +1 -1
- package/dist/sqs/sqsUrl.cjs +92 -6
- package/dist/sqs/sqsUrl.cjs.map +1 -0
- package/dist/sqs/sqsUrl.d.cts +56 -2
- package/dist/sqs/sqsUrl.d.cts.map +1 -0
- package/dist/sqs/sqsUrl.d.mts +56 -2
- package/dist/sqs/sqsUrl.d.mts.map +1 -0
- package/dist/sqs/sqsUrl.mjs +82 -2
- package/dist/sqs/sqsUrl.mjs.map +1 -0
- package/dist/telemetry-DG3l807O.cjs +309 -0
- package/dist/telemetry-DG3l807O.cjs.map +1 -0
- package/dist/telemetry-DjjgJMul.mjs +244 -0
- package/dist/telemetry-DjjgJMul.mjs.map +1 -0
- package/package.json +8 -3
- package/dist/PgBossConnection-23soZ_aM.cjs +0 -80
- package/dist/PgBossConnection-23soZ_aM.cjs.map +0 -1
- package/dist/PgBossConnection-CCXhoNzb.cjs +0 -4
- package/dist/PgBossConnection-DvNbd4Zk.mjs +0 -74
- package/dist/PgBossConnection-DvNbd4Zk.mjs.map +0 -1
- package/dist/PgBossConnection-_gdM40JB.mjs +0 -4
- package/dist/RabbitMQConnection-BKEdCUro.cjs +0 -113
- package/dist/RabbitMQConnection-BKEdCUro.cjs.map +0 -1
- package/dist/RabbitMQConnection-CCOqDDnb.cjs +0 -4
- package/dist/RabbitMQConnection-DJEyM-Bu.mjs +0 -4
- package/dist/RabbitMQConnection-DJgUPc19.mjs +0 -107
- package/dist/RabbitMQConnection-DJgUPc19.mjs.map +0 -1
- package/dist/SNSConnection-B2K86hpz.cjs +0 -75
- package/dist/SNSConnection-B2K86hpz.cjs.map +0 -1
- package/dist/SNSConnection-BVo84FeW.mjs +0 -5
- package/dist/SNSConnection-DIHRjrQF.cjs +0 -5
- package/dist/SNSConnection-v9jjF99w.mjs +0 -69
- package/dist/SNSConnection-v9jjF99w.mjs.map +0 -1
- package/dist/SQSConnection-4tBMkVZE.mjs +0 -69
- package/dist/SQSConnection-4tBMkVZE.mjs.map +0 -1
- package/dist/SQSConnection-BBLAvF-1.cjs +0 -5
- package/dist/SQSConnection-BaC7rGhI.cjs +0 -75
- package/dist/SQSConnection-BaC7rGhI.cjs.map +0 -1
- package/dist/SQSConnection-DbavOq8_.mjs +0 -5
- package/dist/SQSSubscriber-BMWZ3s5q.mjs +0 -114
- package/dist/SQSSubscriber-BMWZ3s5q.mjs.map +0 -1
- package/dist/SQSSubscriber-YXPlg2rm.cjs +0 -120
- package/dist/SQSSubscriber-YXPlg2rm.cjs.map +0 -1
- package/dist/chunk-B9dir_RE.mjs +0 -11
- package/dist/snsUrl-ASdc0D1v.d.cts +0 -61
- package/dist/snsUrl-ASdc0D1v.d.cts.map +0 -1
- package/dist/snsUrl-CifYhPAa.mjs +0 -79
- package/dist/snsUrl-CifYhPAa.mjs.map +0 -1
- package/dist/snsUrl-FRbRcwF0.d.mts +0 -61
- package/dist/snsUrl-FRbRcwF0.d.mts.map +0 -1
- package/dist/snsUrl-f2gU3CzK.cjs +0 -114
- package/dist/snsUrl-f2gU3CzK.cjs.map +0 -1
- package/dist/sqsUrl-BV6zS-mi.d.mts +0 -60
- package/dist/sqsUrl-BV6zS-mi.d.mts.map +0 -1
- package/dist/sqsUrl-CbAsBFHI.mjs +0 -80
- package/dist/sqsUrl-CbAsBFHI.mjs.map +0 -1
- package/dist/sqsUrl-CdisN3GU.cjs +0 -115
- package/dist/sqsUrl-CdisN3GU.cjs.map +0 -1
- package/dist/sqsUrl-DZDPHxIk.d.cts +0 -60
- package/dist/sqsUrl-DZDPHxIk.d.cts.map +0 -1
- package/dist/types-BmixGrOD.d.cts +0 -67
- package/dist/types-BmixGrOD.d.cts.map +0 -1
- package/dist/types-Byv8N9ma.cjs +0 -24
- package/dist/types-Byv8N9ma.cjs.map +0 -1
- package/dist/types-CYDt-2RQ.mjs +0 -18
- package/dist/types-CYDt-2RQ.mjs.map +0 -1
- package/dist/types-DycjsYms.d.mts +0 -67
- package/dist/types-DycjsYms.d.mts.map +0 -1
package/dist/pgboss/index.cjs
CHANGED
|
@@ -1,41 +1,159 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rolldown_runtime = require("../rolldown-runtime-C0BPl7ul.cjs");
|
|
3
|
+
const require_telemetry = require("../telemetry-DG3l807O.cjs");
|
|
4
|
+
let pg_boss = require("pg-boss");
|
|
5
|
+
//#region src/pgboss/PgBossConnection.ts
|
|
6
|
+
var PgBossConnection_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({ PgBossConnection: () => PgBossConnection });
|
|
7
|
+
var PgBossConnection = class PgBossConnection {
|
|
8
|
+
config;
|
|
9
|
+
type = "pgboss";
|
|
10
|
+
boss;
|
|
11
|
+
connecting;
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.config = config;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create a PgBossConnection from a connection string.
|
|
17
|
+
* Format: pgboss://user:pass@host:5432/database?schema=pgboss
|
|
18
|
+
*/
|
|
19
|
+
static async fromConnectionString(connectionString) {
|
|
20
|
+
const url = new URL(connectionString);
|
|
21
|
+
const params = url.searchParams;
|
|
22
|
+
const config = {
|
|
23
|
+
connectionString: `postgres://${url.username ? `${url.username}:${url.password}@` : ""}${url.host}${url.pathname}`,
|
|
24
|
+
schema: params.get("schema") || void 0
|
|
25
|
+
};
|
|
26
|
+
const connection = new PgBossConnection(config);
|
|
27
|
+
await connection.connect();
|
|
28
|
+
return connection;
|
|
29
|
+
}
|
|
30
|
+
async connect() {
|
|
31
|
+
if (this.boss) return;
|
|
32
|
+
if (this.connecting) {
|
|
33
|
+
await this.connecting;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this.connecting = (async () => {
|
|
37
|
+
try {
|
|
38
|
+
const applicationName = this.config.applicationName ?? process.env.GKM_APP_NAME;
|
|
39
|
+
const boss = new pg_boss.PgBoss({
|
|
40
|
+
connectionString: this.config.connectionString,
|
|
41
|
+
...this.config.schema && { schema: this.config.schema },
|
|
42
|
+
...applicationName && { application_name: applicationName }
|
|
43
|
+
});
|
|
44
|
+
await boss.start();
|
|
45
|
+
this.boss = boss;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
this.cleanup();
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
})();
|
|
51
|
+
await this.connecting;
|
|
52
|
+
this.connecting = void 0;
|
|
53
|
+
}
|
|
54
|
+
async close() {
|
|
55
|
+
try {
|
|
56
|
+
await this.boss?.stop({ graceful: true });
|
|
57
|
+
} catch {} finally {
|
|
58
|
+
this.cleanup();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
isConnected() {
|
|
62
|
+
return !!this.boss;
|
|
63
|
+
}
|
|
64
|
+
cleanup() {
|
|
65
|
+
this.boss = void 0;
|
|
66
|
+
this.connecting = void 0;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get the underlying pg-boss instance for publishing/subscribing
|
|
70
|
+
*/
|
|
71
|
+
get instance() {
|
|
72
|
+
return this.boss;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/pgboss/errors.ts
|
|
77
|
+
/** pg-boss connected but its instance never started. */
|
|
78
|
+
var PgBossNotStarted = class extends Error {
|
|
79
|
+
constructor() {
|
|
80
|
+
super("pg-boss did not start. Check the database in the connection string is reachable and the role may create the pg-boss schema.");
|
|
81
|
+
this.name = "PgBossNotStarted";
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
/** A topic subscription with no name to give the subscriber's own queue. */
|
|
85
|
+
var PgBossSubscriptionNeedsName = class extends Error {
|
|
86
|
+
topic;
|
|
87
|
+
constructor(topic) {
|
|
88
|
+
super(`Subscribing to topic '${topic}' on pg-boss needs a subscription name: each subscriber drains a queue of its own, and that queue is named for it. Pass \`subscription\`.`);
|
|
89
|
+
this.topic = topic;
|
|
90
|
+
this.name = "PgBossSubscriptionNeedsName";
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
//#endregion
|
|
4
94
|
//#region src/pgboss/PgBossPublisher.ts
|
|
95
|
+
/** The pg-boss event a topic's message type is published as. */
|
|
96
|
+
function topicEvent(topic, type) {
|
|
97
|
+
return `${topic}/${type}`;
|
|
98
|
+
}
|
|
5
99
|
var PgBossPublisher = class PgBossPublisher {
|
|
6
|
-
|
|
100
|
+
connection;
|
|
101
|
+
options;
|
|
102
|
+
constructor(connection, options = {}) {
|
|
7
103
|
this.connection = connection;
|
|
104
|
+
this.options = options;
|
|
8
105
|
}
|
|
9
106
|
/**
|
|
10
107
|
* Create a PgBossPublisher from a connection string.
|
|
11
108
|
* Format: pgboss://user:pass@host:5432/database?schema=pgboss
|
|
12
109
|
*/
|
|
13
|
-
static async fromConnectionString(connectionString) {
|
|
14
|
-
const { PgBossConnection
|
|
15
|
-
const connection = await PgBossConnection
|
|
16
|
-
return new PgBossPublisher(connection);
|
|
110
|
+
static async fromConnectionString(connectionString, options = {}) {
|
|
111
|
+
const { PgBossConnection } = await Promise.resolve().then(() => PgBossConnection_exports);
|
|
112
|
+
const connection = await PgBossConnection.fromConnectionString(connectionString);
|
|
113
|
+
return new PgBossPublisher(connection, options);
|
|
17
114
|
}
|
|
18
115
|
async publish(messages) {
|
|
19
116
|
if (!this.connection.isConnected()) await this.connection.connect();
|
|
20
117
|
const boss = this.connection.instance;
|
|
21
|
-
if (!boss) throw new
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
118
|
+
if (!boss) throw new PgBossNotStarted();
|
|
119
|
+
const { topic } = this.options;
|
|
120
|
+
if (topic) {
|
|
121
|
+
await require_telemetry.publishTraced(messages, (m) => ({
|
|
122
|
+
system: "pgboss",
|
|
123
|
+
destination: topic,
|
|
124
|
+
type: m.type
|
|
125
|
+
}), async (carriers) => {
|
|
126
|
+
for (const [i, m] of messages.entries()) await boss.publish(topicEvent(topic, m.type), require_telemetry.withTraceKey({
|
|
127
|
+
type: m.type,
|
|
128
|
+
payload: m.payload
|
|
129
|
+
}, carriers[i]));
|
|
130
|
+
});
|
|
131
|
+
return;
|
|
31
132
|
}
|
|
133
|
+
await require_telemetry.publishTraced(messages, (m) => ({
|
|
134
|
+
system: "pgboss",
|
|
135
|
+
destination: m.type,
|
|
136
|
+
type: m.type
|
|
137
|
+
}), async (carriers) => {
|
|
138
|
+
const groups = /* @__PURE__ */ new Map();
|
|
139
|
+
for (const [i, m] of messages.entries()) {
|
|
140
|
+
const list = groups.get(m.type) ?? [];
|
|
141
|
+
list.push({ data: require_telemetry.withTraceKey(m.payload, carriers[i]) });
|
|
142
|
+
groups.set(m.type, list);
|
|
143
|
+
}
|
|
144
|
+
for (const [name, jobs] of groups) {
|
|
145
|
+
await boss.createQueue(name);
|
|
146
|
+
await boss.insert(name, jobs);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
32
149
|
}
|
|
33
150
|
async close() {}
|
|
34
151
|
};
|
|
35
|
-
|
|
36
152
|
//#endregion
|
|
37
153
|
//#region src/pgboss/PgBossSubscriber.ts
|
|
38
154
|
var PgBossSubscriber = class PgBossSubscriber {
|
|
155
|
+
connection;
|
|
156
|
+
options;
|
|
39
157
|
constructor(connection, options = {}) {
|
|
40
158
|
this.connection = connection;
|
|
41
159
|
this.options = options;
|
|
@@ -45,10 +163,9 @@ var PgBossSubscriber = class PgBossSubscriber {
|
|
|
45
163
|
* Format: pgboss://user:pass@host:5432/database?schema=pgboss&batchSize=5
|
|
46
164
|
*/
|
|
47
165
|
static async fromConnectionString(connectionString) {
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const connection = await PgBossConnection$1.fromConnectionString(connectionString);
|
|
166
|
+
const params = new URL(connectionString).searchParams;
|
|
167
|
+
const { PgBossConnection } = await Promise.resolve().then(() => PgBossConnection_exports);
|
|
168
|
+
const connection = await PgBossConnection.fromConnectionString(connectionString);
|
|
52
169
|
const options = {
|
|
53
170
|
batchSize: params.get("batchSize") ? Number.parseInt(params.get("batchSize"), 10) : void 0,
|
|
54
171
|
pollingIntervalSeconds: params.get("pollingIntervalSeconds") ? Number.parseInt(params.get("pollingIntervalSeconds"), 10) : void 0
|
|
@@ -58,27 +175,74 @@ var PgBossSubscriber = class PgBossSubscriber {
|
|
|
58
175
|
async subscribe(messages, listener) {
|
|
59
176
|
if (!this.connection.isConnected()) await this.connection.connect();
|
|
60
177
|
const boss = this.connection.instance;
|
|
61
|
-
if (!boss) throw new
|
|
178
|
+
if (!boss) throw new PgBossNotStarted();
|
|
179
|
+
const work = {
|
|
180
|
+
...this.options.batchSize && { batchSize: this.options.batchSize },
|
|
181
|
+
...this.options.pollingIntervalSeconds && { pollingIntervalSeconds: this.options.pollingIntervalSeconds }
|
|
182
|
+
};
|
|
183
|
+
const { topic, subscription } = this.options;
|
|
184
|
+
if (topic) {
|
|
185
|
+
if (!subscription) throw new PgBossSubscriptionNeedsName(topic);
|
|
186
|
+
const queue = topicEvent(topic, subscription);
|
|
187
|
+
await boss.createQueue(queue);
|
|
188
|
+
for (const type of messages) await boss.subscribe(topicEvent(topic, type), queue);
|
|
189
|
+
await boss.work(queue, work, async (jobs) => {
|
|
190
|
+
for (const job of jobs) {
|
|
191
|
+
const { data, carrier } = require_telemetry.withoutTraceKey(job.data);
|
|
192
|
+
await require_telemetry.consumeTraced({
|
|
193
|
+
system: "pgboss",
|
|
194
|
+
destination: topic,
|
|
195
|
+
type: data.type,
|
|
196
|
+
messageId: job.id
|
|
197
|
+
}, carrier, () => listener({
|
|
198
|
+
type: data.type,
|
|
199
|
+
payload: data.payload
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
62
205
|
for (const messageType of messages) {
|
|
63
206
|
await boss.createQueue(messageType);
|
|
64
|
-
await boss.work(messageType, {
|
|
65
|
-
...this.options.batchSize && { batchSize: this.options.batchSize },
|
|
66
|
-
...this.options.pollingIntervalSeconds && { pollingIntervalSeconds: this.options.pollingIntervalSeconds }
|
|
67
|
-
}, async (jobs) => {
|
|
207
|
+
await boss.work(messageType, work, async (jobs) => {
|
|
68
208
|
for (const job of jobs) {
|
|
69
|
-
const
|
|
209
|
+
const { data, carrier } = require_telemetry.withoutTraceKey(job.data);
|
|
210
|
+
await require_telemetry.consumeTraced({
|
|
211
|
+
system: "pgboss",
|
|
212
|
+
destination: messageType,
|
|
70
213
|
type: job.name,
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
214
|
+
messageId: job.id
|
|
215
|
+
}, carrier, () => listener({
|
|
216
|
+
type: job.name,
|
|
217
|
+
payload: data
|
|
218
|
+
}));
|
|
74
219
|
}
|
|
75
220
|
});
|
|
76
221
|
}
|
|
77
222
|
}
|
|
78
223
|
};
|
|
79
|
-
|
|
80
224
|
//#endregion
|
|
81
|
-
|
|
225
|
+
//#region src/pgboss/driver.ts
|
|
226
|
+
/**
|
|
227
|
+
* `pgboss://` — queues and topics in Postgres. Register it with
|
|
228
|
+
* `registerEventsDriver(pgbossEventsDriver)`; this subpath is the only one
|
|
229
|
+
* that imports `pg-boss`.
|
|
230
|
+
*/
|
|
231
|
+
const pgbossEventsDriver = {
|
|
232
|
+
scheme: "pgboss",
|
|
233
|
+
connect: (url) => PgBossConnection.fromConnectionString(url),
|
|
234
|
+
publisher: (url, options) => PgBossPublisher.fromConnectionString(url, options),
|
|
235
|
+
publisherFor: (connection, options) => new PgBossPublisher(connection, options),
|
|
236
|
+
subscriber: (url) => PgBossSubscriber.fromConnectionString(url),
|
|
237
|
+
subscriberFor: (connection, options) => new PgBossSubscriber(connection, options)
|
|
238
|
+
};
|
|
239
|
+
//#endregion
|
|
240
|
+
exports.PgBossConnection = PgBossConnection;
|
|
241
|
+
exports.PgBossNotStarted = PgBossNotStarted;
|
|
82
242
|
exports.PgBossPublisher = PgBossPublisher;
|
|
83
243
|
exports.PgBossSubscriber = PgBossSubscriber;
|
|
244
|
+
exports.PgBossSubscriptionNeedsName = PgBossSubscriptionNeedsName;
|
|
245
|
+
exports.pgbossEventsDriver = pgbossEventsDriver;
|
|
246
|
+
exports.topicEvent = topicEvent;
|
|
247
|
+
|
|
84
248
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["connection: PgBossConnection","connectionString: string","messages: TMessage[]","connection: PgBossConnection","options: PgBossSubscriberOptions","connectionString: string","messages: TMessage['type'][]","listener: (payload: TMessage) => Promise<void>"],"sources":["../../src/pgboss/PgBossPublisher.ts","../../src/pgboss/PgBossSubscriber.ts"],"sourcesContent":["import type { EventPublisher, PublishableMessage } from '../types';\nimport type { PgBossConnection } from './PgBossConnection';\n\nexport class PgBossPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\tconstructor(private connection: PgBossConnection) {}\n\n\t/**\n\t * Create a PgBossPublisher from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<PgBossPublisher<TMessage>> {\n\t\tconst { PgBossConnection } = await import('./PgBossConnection');\n\t\tconst connection =\n\t\t\tawait PgBossConnection.fromConnectionString(connectionString);\n\t\treturn new PgBossPublisher<TMessage>(connection);\n\t}\n\n\tasync publish(messages: TMessage[]): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst boss = this.connection.instance;\n\t\tif (!boss) {\n\t\t\tthrow new Error('PgBoss instance not initialized');\n\t\t}\n\n\t\t// Group jobs by queue name (v11+ requires per-queue insert calls)\n\t\tconst groups = new Map<string, { data: TMessage['payload'] }[]>();\n\t\tfor (const m of messages) {\n\t\t\tconst list = groups.get(m.type) ?? [];\n\t\t\tlist.push({ data: m.payload });\n\t\t\tgroups.set(m.type, list);\n\t\t}\n\n\t\tfor (const [name, jobs] of groups) {\n\t\t\tawait boss.createQueue(name);\n\t\t\tawait boss.insert(name, jobs);\n\t\t}\n\t}\n\n\tasync close(): Promise<void> {\n\t\t// Publisher doesn't own the connection\n\t}\n}\n","import type { EventSubscriber, PublishableMessage } from '../types';\nimport type { PgBossConnection } from './PgBossConnection';\n\nexport interface PgBossSubscriberOptions {\n\tbatchSize?: number;\n\tpollingIntervalSeconds?: number;\n}\n\nexport class PgBossSubscriber<TMessage extends PublishableMessage<string, any>>\n\timplements EventSubscriber<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: PgBossConnection,\n\t\tprivate options: PgBossSubscriberOptions = {},\n\t) {}\n\n\t/**\n\t * Create a PgBossSubscriber from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss&batchSize=5\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<PgBossSubscriber<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { PgBossConnection } = await import('./PgBossConnection');\n\t\tconst connection =\n\t\t\tawait PgBossConnection.fromConnectionString(connectionString);\n\n\t\tconst options: PgBossSubscriberOptions = {\n\t\t\tbatchSize: params.get('batchSize')\n\t\t\t\t? Number.parseInt(params.get('batchSize')!, 10)\n\t\t\t\t: undefined,\n\t\t\tpollingIntervalSeconds: params.get('pollingIntervalSeconds')\n\t\t\t\t? Number.parseInt(params.get('pollingIntervalSeconds')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new PgBossSubscriber<TMessage>(connection, options);\n\t}\n\n\tasync subscribe(\n\t\tmessages: TMessage['type'][],\n\t\tlistener: (payload: TMessage) => Promise<void>,\n\t): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst boss = this.connection.instance;\n\t\tif (!boss) {\n\t\t\tthrow new Error('PgBoss instance not initialized');\n\t\t}\n\n\t\tfor (const messageType of messages) {\n\t\t\tawait boss.createQueue(messageType);\n\t\t\tawait boss.work(\n\t\t\t\tmessageType,\n\t\t\t\t{\n\t\t\t\t\t...(this.options.batchSize && {\n\t\t\t\t\t\tbatchSize: this.options.batchSize,\n\t\t\t\t\t}),\n\t\t\t\t\t...(this.options.pollingIntervalSeconds && {\n\t\t\t\t\t\tpollingIntervalSeconds: this.options.pollingIntervalSeconds,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t\tasync (jobs) => {\n\t\t\t\t\tfor (const job of jobs) {\n\t\t\t\t\t\tconst fullMessage = {\n\t\t\t\t\t\t\ttype: job.name,\n\t\t\t\t\t\t\tpayload: job.data,\n\t\t\t\t\t\t} as TMessage;\n\n\t\t\t\t\t\tawait listener(fullMessage);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n}\n"],"mappings":";;;;AAGA,IAAa,kBAAb,MAAa,gBAEb;CACC,YAAoBA,YAA8B;EAA9B;CAAgC;;;;;CAMpD,aAAa,qBAEXC,kBAA8D;EAC/D,MAAM,EAAE,sCAAkB,GAAG,2CAAM;EACnC,MAAM,aACL,MAAM,mBAAiB,qBAAqB,iBAAiB;AAC9D,SAAO,IAAI,gBAA0B;CACrC;CAED,MAAM,QAAQC,UAAqC;AAClD,OAAK,KAAK,WAAW,aAAa,CACjC,OAAM,KAAK,WAAW,SAAS;EAGhC,MAAM,OAAO,KAAK,WAAW;AAC7B,OAAK,KACJ,OAAM,IAAI,MAAM;EAIjB,MAAM,yBAAS,IAAI;AACnB,OAAK,MAAM,KAAK,UAAU;GACzB,MAAM,OAAO,OAAO,IAAI,EAAE,KAAK,IAAI,CAAE;AACrC,QAAK,KAAK,EAAE,MAAM,EAAE,QAAS,EAAC;AAC9B,UAAO,IAAI,EAAE,MAAM,KAAK;EACxB;AAED,OAAK,MAAM,CAAC,MAAM,KAAK,IAAI,QAAQ;AAClC,SAAM,KAAK,YAAY,KAAK;AAC5B,SAAM,KAAK,OAAO,MAAM,KAAK;EAC7B;CACD;CAED,MAAM,QAAuB,CAE5B;AACD;;;;ACxCD,IAAa,mBAAb,MAAa,iBAEb;CACC,YACSC,YACAC,UAAmC,CAAE,GAC5C;EAFO;EACA;CACL;;;;;CAMJ,aAAa,qBAEXC,kBAA+D;EAChE,MAAM,MAAM,IAAI,IAAI;EACpB,MAAM,SAAS,IAAI;EAEnB,MAAM,EAAE,sCAAkB,GAAG,2CAAM;EACnC,MAAM,aACL,MAAM,mBAAiB,qBAAqB,iBAAiB;EAE9D,MAAMD,UAAmC;GACxC,WAAW,OAAO,IAAI,YAAY,GAC/B,OAAO,SAAS,OAAO,IAAI,YAAY,EAAG,GAAG;GAEhD,wBAAwB,OAAO,IAAI,yBAAyB,GACzD,OAAO,SAAS,OAAO,IAAI,yBAAyB,EAAG,GAAG;EAE7D;AAED,SAAO,IAAI,iBAA2B,YAAY;CAClD;CAED,MAAM,UACLE,UACAC,UACgB;AAChB,OAAK,KAAK,WAAW,aAAa,CACjC,OAAM,KAAK,WAAW,SAAS;EAGhC,MAAM,OAAO,KAAK,WAAW;AAC7B,OAAK,KACJ,OAAM,IAAI,MAAM;AAGjB,OAAK,MAAM,eAAe,UAAU;AACnC,SAAM,KAAK,YAAY,YAAY;AACnC,SAAM,KAAK,KACV,aACA;IACC,GAAI,KAAK,QAAQ,aAAa,EAC7B,WAAW,KAAK,QAAQ,UACxB;IACD,GAAI,KAAK,QAAQ,0BAA0B,EAC1C,wBAAwB,KAAK,QAAQ,uBACrC;GACD,GACD,OAAO,SAAS;AACf,SAAK,MAAM,OAAO,MAAM;KACvB,MAAM,cAAc;MACnB,MAAM,IAAI;MACV,SAAS,IAAI;KACb;AAED,WAAM,SAAS,YAAY;IAC3B;GACD,EACD;EACD;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["PgBoss","publishTraced","withTraceKey","withoutTraceKey","consumeTraced"],"sources":["../../src/pgboss/PgBossConnection.ts","../../src/pgboss/errors.ts","../../src/pgboss/PgBossPublisher.ts","../../src/pgboss/PgBossSubscriber.ts","../../src/pgboss/driver.ts"],"sourcesContent":["import { PgBoss } from 'pg-boss';\nimport type { EventConnection } from '../types';\nimport { EventPublisherType } from '../types';\n\nexport interface PgBossConnectionConfig {\n\tconnectionString: string;\n\tschema?: string;\n\t/**\n\t * Who this connection is to Postgres. Defaults to `GKM_APP_NAME`, which a\n\t * generated entry sets to the construct it runs — so the broker's\n\t * connections are named for the process that holds them, as its database\n\t * pools are, rather than all being `pgboss`.\n\t */\n\tapplicationName?: string;\n}\n\nexport class PgBossConnection implements EventConnection {\n\treadonly type = EventPublisherType.PgBoss;\n\tprivate boss?: PgBoss;\n\tprivate connecting?: Promise<void>;\n\n\tconstructor(private config: PgBossConnectionConfig) {}\n\n\t/**\n\t * Create a PgBossConnection from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss\n\t */\n\tstatic async fromConnectionString(\n\t\tconnectionString: string,\n\t): Promise<PgBossConnection> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst postgresUrl = `postgres://${url.username ? `${url.username}:${url.password}@` : ''}${url.host}${url.pathname}`;\n\n\t\tconst config: PgBossConnectionConfig = {\n\t\t\tconnectionString: postgresUrl,\n\t\t\tschema: params.get('schema') || undefined,\n\t\t};\n\n\t\tconst connection = new PgBossConnection(config);\n\t\tawait connection.connect();\n\t\treturn connection;\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tif (this.boss) return;\n\n\t\tif (this.connecting) {\n\t\t\tawait this.connecting;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.connecting = (async () => {\n\t\t\ttry {\n\t\t\t\tconst applicationName =\n\t\t\t\t\tthis.config.applicationName ?? process.env.GKM_APP_NAME;\n\t\t\t\tconst boss = new PgBoss({\n\t\t\t\t\tconnectionString: this.config.connectionString,\n\t\t\t\t\t...(this.config.schema && { schema: this.config.schema }),\n\t\t\t\t\t...(applicationName && { application_name: applicationName }),\n\t\t\t\t});\n\n\t\t\t\tawait boss.start();\n\t\t\t\tthis.boss = boss;\n\t\t\t} catch (error) {\n\t\t\t\tthis.cleanup();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})();\n\n\t\tawait this.connecting;\n\t\tthis.connecting = undefined;\n\t}\n\n\tasync close(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.boss?.stop({ graceful: true });\n\t\t} catch {\n\t\t\t// Ignore errors during close\n\t\t} finally {\n\t\t\tthis.cleanup();\n\t\t}\n\t}\n\n\tisConnected(): boolean {\n\t\treturn !!this.boss;\n\t}\n\n\tprivate cleanup(): void {\n\t\tthis.boss = undefined;\n\t\tthis.connecting = undefined;\n\t}\n\n\t/**\n\t * Get the underlying pg-boss instance for publishing/subscribing\n\t */\n\tget instance(): PgBoss | undefined {\n\t\treturn this.boss;\n\t}\n}\n","// Beside the adapter but apart from its connection module, which imports\n// the broker's client: the publisher and subscriber load that lazily, and\n// importing an error class from it would load it eagerly.\n\n/** pg-boss connected but its instance never started. */\nexport class PgBossNotStarted extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'pg-boss did not start. Check the database in the connection string is reachable and the role may create the pg-boss schema.',\n\t\t);\n\t\tthis.name = 'PgBossNotStarted';\n\t}\n}\n\n/** A topic subscription with no name to give the subscriber's own queue. */\nexport class PgBossSubscriptionNeedsName extends Error {\n\tconstructor(readonly topic: string) {\n\t\tsuper(\n\t\t\t`Subscribing to topic '${topic}' on pg-boss needs a subscription name: ` +\n\t\t\t\t'each subscriber drains a queue of its own, and that queue is named ' +\n\t\t\t\t'for it. Pass `subscription`.',\n\t\t);\n\t\tthis.name = 'PgBossSubscriptionNeedsName';\n\t}\n}\n","import { publishTraced, withTraceKey } from '../telemetry';\nimport type { EventPublisher, PublishableMessage } from '../types';\nimport { PgBossNotStarted } from './errors';\nimport type { PgBossConnection } from './PgBossConnection';\n\nexport interface PgBossPublisherOptions {\n\t/**\n\t * Publishing to a topic: each message is fanned out to every subscriber's\n\t * own queue rather than inserted into one shared queue. Without it, a\n\t * message goes to the queue named by its type — a work queue, one consumer.\n\t */\n\ttopic?: string;\n}\n\n/** The pg-boss event a topic's message type is published as. */\nexport function topicEvent(topic: string, type: string): string {\n\treturn `${topic}/${type}`;\n}\n\nexport class PgBossPublisher<TMessage extends PublishableMessage<string, any>>\n\timplements EventPublisher<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: PgBossConnection,\n\t\tprivate options: PgBossPublisherOptions = {},\n\t) {}\n\n\t/**\n\t * Create a PgBossPublisher from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(\n\t\tconnectionString: string,\n\t\toptions: PgBossPublisherOptions = {},\n\t): Promise<PgBossPublisher<TMessage>> {\n\t\tconst { PgBossConnection } = await import('./PgBossConnection');\n\t\tconst connection =\n\t\t\tawait PgBossConnection.fromConnectionString(connectionString);\n\t\treturn new PgBossPublisher<TMessage>(connection, options);\n\t}\n\n\tasync publish(messages: TMessage[]): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst boss = this.connection.instance;\n\t\tif (!boss) {\n\t\t\tthrow new PgBossNotStarted();\n\t\t}\n\n\t\t// A topic: pg-boss copies the job into every queue subscribed to the\n\t\t// event — one per subscriber — so each subscriber sees each message.\n\t\t// The type rides in the data, because the job is named for the queue.\n\t\t//\n\t\t// pg-boss has no header field, so the trace context rides in the data\n\t\t// too, under a reserved key the subscriber removes before the handler.\n\t\tconst { topic } = this.options;\n\t\tif (topic) {\n\t\t\tawait publishTraced(\n\t\t\t\tmessages,\n\t\t\t\t(m) => ({ system: 'pgboss', destination: topic, type: m.type }),\n\t\t\t\tasync (carriers) => {\n\t\t\t\t\tfor (const [i, m] of messages.entries()) {\n\t\t\t\t\t\tawait boss.publish(\n\t\t\t\t\t\t\ttopicEvent(topic, m.type),\n\t\t\t\t\t\t\twithTraceKey({ type: m.type, payload: m.payload }, carriers[i]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tawait publishTraced(\n\t\t\tmessages,\n\t\t\t(m) => ({ system: 'pgboss', destination: m.type, type: m.type }),\n\t\t\tasync (carriers) => {\n\t\t\t\t// Group jobs by queue name (v11+ requires per-queue insert calls)\n\t\t\t\tconst groups = new Map<string, { data: TMessage['payload'] }[]>();\n\t\t\t\tfor (const [i, m] of messages.entries()) {\n\t\t\t\t\tconst list = groups.get(m.type) ?? [];\n\t\t\t\t\tlist.push({ data: withTraceKey(m.payload, carriers[i]) });\n\t\t\t\t\tgroups.set(m.type, list);\n\t\t\t\t}\n\n\t\t\t\tfor (const [name, jobs] of groups) {\n\t\t\t\t\tawait boss.createQueue(name);\n\t\t\t\t\tawait boss.insert(name, jobs);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tasync close(): Promise<void> {\n\t\t// Publisher doesn't own the connection\n\t}\n}\n","import { consumeTraced, withoutTraceKey } from '../telemetry';\nimport type { EventSubscriber, PublishableMessage } from '../types';\nimport { PgBossNotStarted, PgBossSubscriptionNeedsName } from './errors';\nimport type { PgBossConnection } from './PgBossConnection';\nimport { topicEvent } from './PgBossPublisher';\n\nexport interface PgBossSubscriberOptions {\n\tbatchSize?: number;\n\tpollingIntervalSeconds?: number;\n\t/**\n\t * Subscribing to a topic. Each subscriber then drains a queue of its own,\n\t * `<topic>/<subscription>`, bound to the events it names — so every\n\t * subscriber sees every message, and replicas of one subscriber share it.\n\t * Without it, messages are drained from the queue named by their type:\n\t * work shared among whoever drains it.\n\t */\n\ttopic?: string;\n\t/** The subscriber's own name on the topic. Required with `topic`. */\n\tsubscription?: string;\n}\n\nexport class PgBossSubscriber<TMessage extends PublishableMessage<string, any>>\n\timplements EventSubscriber<TMessage>\n{\n\tconstructor(\n\t\tprivate connection: PgBossConnection,\n\t\tprivate options: PgBossSubscriberOptions = {},\n\t) {}\n\n\t/**\n\t * Create a PgBossSubscriber from a connection string.\n\t * Format: pgboss://user:pass@host:5432/database?schema=pgboss&batchSize=5\n\t */\n\tstatic async fromConnectionString<\n\t\tTMessage extends PublishableMessage<string, any>,\n\t>(connectionString: string): Promise<PgBossSubscriber<TMessage>> {\n\t\tconst url = new URL(connectionString);\n\t\tconst params = url.searchParams;\n\n\t\tconst { PgBossConnection } = await import('./PgBossConnection');\n\t\tconst connection =\n\t\t\tawait PgBossConnection.fromConnectionString(connectionString);\n\n\t\tconst options: PgBossSubscriberOptions = {\n\t\t\tbatchSize: params.get('batchSize')\n\t\t\t\t? Number.parseInt(params.get('batchSize')!, 10)\n\t\t\t\t: undefined,\n\t\t\tpollingIntervalSeconds: params.get('pollingIntervalSeconds')\n\t\t\t\t? Number.parseInt(params.get('pollingIntervalSeconds')!, 10)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn new PgBossSubscriber<TMessage>(connection, options);\n\t}\n\n\tasync subscribe(\n\t\tmessages: TMessage['type'][],\n\t\tlistener: (payload: TMessage) => Promise<void>,\n\t): Promise<void> {\n\t\tif (!this.connection.isConnected()) {\n\t\t\tawait this.connection.connect();\n\t\t}\n\n\t\tconst boss = this.connection.instance;\n\t\tif (!boss) {\n\t\t\tthrow new PgBossNotStarted();\n\t\t}\n\n\t\tconst work = {\n\t\t\t...(this.options.batchSize && { batchSize: this.options.batchSize }),\n\t\t\t...(this.options.pollingIntervalSeconds && {\n\t\t\t\tpollingIntervalSeconds: this.options.pollingIntervalSeconds,\n\t\t\t}),\n\t\t};\n\n\t\tconst { topic, subscription } = this.options;\n\t\tif (topic) {\n\t\t\tif (!subscription) throw new PgBossSubscriptionNeedsName(topic);\n\n\t\t\tconst queue = topicEvent(topic, subscription);\n\t\t\tawait boss.createQueue(queue);\n\t\t\tfor (const type of messages) {\n\t\t\t\tawait boss.subscribe(topicEvent(topic, type), queue);\n\t\t\t}\n\t\t\tawait boss.work<{ type: string; payload: unknown }>(\n\t\t\t\tqueue,\n\t\t\t\twork,\n\t\t\t\tasync (jobs) => {\n\t\t\t\t\tfor (const job of jobs) {\n\t\t\t\t\t\tconst { data, carrier } = withoutTraceKey(job.data);\n\t\t\t\t\t\tawait consumeTraced(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsystem: 'pgboss',\n\t\t\t\t\t\t\t\tdestination: topic,\n\t\t\t\t\t\t\t\ttype: data.type,\n\t\t\t\t\t\t\t\tmessageId: job.id,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcarrier,\n\t\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t\tlistener({\n\t\t\t\t\t\t\t\t\ttype: data.type,\n\t\t\t\t\t\t\t\t\tpayload: data.payload,\n\t\t\t\t\t\t\t\t} as TMessage),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const messageType of messages) {\n\t\t\tawait boss.createQueue(messageType);\n\t\t\tawait boss.work(messageType, work, async (jobs) => {\n\t\t\t\tfor (const job of jobs) {\n\t\t\t\t\t// The trace context is taken out of the data here, so the\n\t\t\t\t\t// handler's payload is exactly what was published.\n\t\t\t\t\tconst { data, carrier } = withoutTraceKey(job.data);\n\t\t\t\t\tawait consumeTraced(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsystem: 'pgboss',\n\t\t\t\t\t\t\tdestination: messageType,\n\t\t\t\t\t\t\ttype: job.name,\n\t\t\t\t\t\t\tmessageId: job.id,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcarrier,\n\t\t\t\t\t\t() => listener({ type: job.name, payload: data } as TMessage),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n}\n","import type { EventsDriver } from '../registry';\nimport { EventPublisherType } from '../types';\nimport { PgBossConnection } from './PgBossConnection';\nimport { PgBossPublisher } from './PgBossPublisher';\nimport { PgBossSubscriber } from './PgBossSubscriber';\n\n/**\n * `pgboss://` — queues and topics in Postgres. Register it with\n * `registerEventsDriver(pgbossEventsDriver)`; this subpath is the only one\n * that imports `pg-boss`.\n */\nexport const pgbossEventsDriver: EventsDriver = {\n\tscheme: EventPublisherType.PgBoss,\n\tconnect: (url) => PgBossConnection.fromConnectionString(url),\n\tpublisher: (url, options) =>\n\t\tPgBossPublisher.fromConnectionString(url, options),\n\tpublisherFor: (connection, options) =>\n\t\tnew PgBossPublisher(connection as PgBossConnection, options),\n\tsubscriber: (url) => PgBossSubscriber.fromConnectionString(url),\n\tsubscriberFor: (connection, options) =>\n\t\tnew PgBossSubscriber(connection as PgBossConnection, options),\n};\n"],"mappings":"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"}
|
package/dist/pgboss/index.d.cts
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as EventPublisher, f as EventPublisherType, g as PublishableMessage, p as EventSubscriber, t as EventsDriver, u as EventConnection } from "../registry-DIx25Q5s.cjs";
|
|
2
2
|
import { PgBoss } from "pg-boss";
|
|
3
|
-
|
|
3
|
+
//#region src/pgboss/driver.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* `pgboss://` — queues and topics in Postgres. Register it with
|
|
6
|
+
* `registerEventsDriver(pgbossEventsDriver)`; this subpath is the only one
|
|
7
|
+
* that imports `pg-boss`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const pgbossEventsDriver: EventsDriver;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/pgboss/errors.d.ts
|
|
12
|
+
/** pg-boss connected but its instance never started. */
|
|
13
|
+
export declare class PgBossNotStarted extends Error {
|
|
14
|
+
constructor();
|
|
15
|
+
}
|
|
16
|
+
/** A topic subscription with no name to give the subscriber's own queue. */
|
|
17
|
+
export declare class PgBossSubscriptionNeedsName extends Error {
|
|
18
|
+
readonly topic: string;
|
|
19
|
+
constructor(topic: string);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
4
22
|
//#region src/pgboss/PgBossConnection.d.ts
|
|
5
23
|
interface PgBossConnectionConfig {
|
|
6
24
|
connectionString: string;
|
|
7
25
|
schema?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Who this connection is to Postgres. Defaults to `GKM_APP_NAME`, which a
|
|
28
|
+
* generated entry sets to the construct it runs — so the broker's
|
|
29
|
+
* connections are named for the process that holds them, as its database
|
|
30
|
+
* pools are, rather than all being `pgboss`.
|
|
31
|
+
*/
|
|
32
|
+
applicationName?: string;
|
|
8
33
|
}
|
|
9
|
-
declare class PgBossConnection implements EventConnection {
|
|
34
|
+
export declare class PgBossConnection implements EventConnection {
|
|
10
35
|
private config;
|
|
11
36
|
readonly type = EventPublisherType.PgBoss;
|
|
12
37
|
private boss?;
|
|
@@ -26,28 +51,47 @@ declare class PgBossConnection implements EventConnection {
|
|
|
26
51
|
*/
|
|
27
52
|
get instance(): PgBoss | undefined;
|
|
28
53
|
}
|
|
29
|
-
//# sourceMappingURL=PgBossConnection.d.ts.map
|
|
30
54
|
//#endregion
|
|
31
55
|
//#region src/pgboss/PgBossPublisher.d.ts
|
|
32
|
-
|
|
56
|
+
interface PgBossPublisherOptions {
|
|
57
|
+
/**
|
|
58
|
+
* Publishing to a topic: each message is fanned out to every subscriber's
|
|
59
|
+
* own queue rather than inserted into one shared queue. Without it, a
|
|
60
|
+
* message goes to the queue named by its type — a work queue, one consumer.
|
|
61
|
+
*/
|
|
62
|
+
topic?: string;
|
|
63
|
+
}
|
|
64
|
+
/** The pg-boss event a topic's message type is published as. */
|
|
65
|
+
export declare function topicEvent(topic: string, type: string): string;
|
|
66
|
+
export declare class PgBossPublisher<TMessage extends PublishableMessage<string, any>> implements EventPublisher<TMessage> {
|
|
33
67
|
private connection;
|
|
34
|
-
|
|
68
|
+
private options;
|
|
69
|
+
constructor(connection: PgBossConnection, options?: PgBossPublisherOptions);
|
|
35
70
|
/**
|
|
36
71
|
* Create a PgBossPublisher from a connection string.
|
|
37
72
|
* Format: pgboss://user:pass@host:5432/database?schema=pgboss
|
|
38
73
|
*/
|
|
39
|
-
static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionString: string): Promise<PgBossPublisher<TMessage>>;
|
|
74
|
+
static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionString: string, options?: PgBossPublisherOptions): Promise<PgBossPublisher<TMessage>>;
|
|
40
75
|
publish(messages: TMessage[]): Promise<void>;
|
|
41
76
|
close(): Promise<void>;
|
|
42
77
|
}
|
|
43
|
-
//# sourceMappingURL=PgBossPublisher.d.ts.map
|
|
44
78
|
//#endregion
|
|
45
79
|
//#region src/pgboss/PgBossSubscriber.d.ts
|
|
46
80
|
interface PgBossSubscriberOptions {
|
|
47
81
|
batchSize?: number;
|
|
48
82
|
pollingIntervalSeconds?: number;
|
|
83
|
+
/**
|
|
84
|
+
* Subscribing to a topic. Each subscriber then drains a queue of its own,
|
|
85
|
+
* `<topic>/<subscription>`, bound to the events it names — so every
|
|
86
|
+
* subscriber sees every message, and replicas of one subscriber share it.
|
|
87
|
+
* Without it, messages are drained from the queue named by their type:
|
|
88
|
+
* work shared among whoever drains it.
|
|
89
|
+
*/
|
|
90
|
+
topic?: string;
|
|
91
|
+
/** The subscriber's own name on the topic. Required with `topic`. */
|
|
92
|
+
subscription?: string;
|
|
49
93
|
}
|
|
50
|
-
declare class PgBossSubscriber<TMessage extends PublishableMessage<string, any>> implements EventSubscriber<TMessage> {
|
|
94
|
+
export declare class PgBossSubscriber<TMessage extends PublishableMessage<string, any>> implements EventSubscriber<TMessage> {
|
|
51
95
|
private connection;
|
|
52
96
|
private options;
|
|
53
97
|
constructor(connection: PgBossConnection, options?: PgBossSubscriberOptions);
|
|
@@ -58,8 +102,6 @@ declare class PgBossSubscriber<TMessage extends PublishableMessage<string, any>>
|
|
|
58
102
|
static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionString: string): Promise<PgBossSubscriber<TMessage>>;
|
|
59
103
|
subscribe(messages: TMessage['type'][], listener: (payload: TMessage) => Promise<void>): Promise<void>;
|
|
60
104
|
}
|
|
61
|
-
//# sourceMappingURL=PgBossSubscriber.d.ts.map
|
|
62
|
-
|
|
63
105
|
//#endregion
|
|
64
|
-
export {
|
|
106
|
+
export type { PgBossConnectionConfig, PgBossPublisherOptions, PgBossSubscriberOptions };
|
|
65
107
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/pgboss/PgBossConnection.ts","../../src/pgboss/PgBossPublisher.ts","../../src/pgboss/PgBossSubscriber.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/pgboss/driver.ts","../../src/pgboss/errors.ts","../../src/pgboss/PgBossConnection.ts","../../src/pgboss/PgBossPublisher.ts","../../src/pgboss/PgBossSubscriber.ts"],"mappings":";;;;;;;;qBAWa,oBAAoB;;;;qBCNpB,yBAAyB;EACrC;;;qBASY,oCAAoC;WAC3B;EAArB,YAAqB;;;;UCZL;EAChB;EACA;;;;;;;EAOA;;qBAGY,4BAA4B;UAKpB;WAJX,OAAI,mBAAA;UACL;UACA;EAER,YAAoB,QAAQ;;;;;SAMf,qBACZ,2BACE,QAAQ;EAgBL,WAAW;EA8BX,SAAS;EAUf;UAIQ;;;;MAQJ,YAAY;;;;UC5FA;;;;;;EAMhB;;;wBAIe,WAAW,eAAe;qBAI7B,gBAAgB,iBAAiB,4CAClC,eAAe;UAGjB;UACA;EAFT,YACS,YAAY,kBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAEjB,0BACA,UAAS,yBACP,QAAQ,gBAAgB;EAOrB,QAAQ,UAAU,aAAa;EAqD/B,SAAS;;;;UC1FC;EAChB;EACA;;;;;;;;EAQA;;EAEA;;qBAGY,iBAAiB,iBAAiB,4CACnC,gBAAgB;UAGlB;UACA;EAFT,YACS,YAAY,kBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,iBAAiB;EAoBhD,UACL,UAAU,oBACV,WAAW,SAAS,aAAa,gBAC/B"}
|
package/dist/pgboss/index.d.mts
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as EventPublisher, f as EventPublisherType, g as PublishableMessage, p as EventSubscriber, t as EventsDriver, u as EventConnection } from "../registry-DIx25Q5s.mjs";
|
|
2
2
|
import { PgBoss } from "pg-boss";
|
|
3
|
-
|
|
3
|
+
//#region src/pgboss/driver.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* `pgboss://` — queues and topics in Postgres. Register it with
|
|
6
|
+
* `registerEventsDriver(pgbossEventsDriver)`; this subpath is the only one
|
|
7
|
+
* that imports `pg-boss`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const pgbossEventsDriver: EventsDriver;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/pgboss/errors.d.ts
|
|
12
|
+
/** pg-boss connected but its instance never started. */
|
|
13
|
+
export declare class PgBossNotStarted extends Error {
|
|
14
|
+
constructor();
|
|
15
|
+
}
|
|
16
|
+
/** A topic subscription with no name to give the subscriber's own queue. */
|
|
17
|
+
export declare class PgBossSubscriptionNeedsName extends Error {
|
|
18
|
+
readonly topic: string;
|
|
19
|
+
constructor(topic: string);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
4
22
|
//#region src/pgboss/PgBossConnection.d.ts
|
|
5
23
|
interface PgBossConnectionConfig {
|
|
6
24
|
connectionString: string;
|
|
7
25
|
schema?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Who this connection is to Postgres. Defaults to `GKM_APP_NAME`, which a
|
|
28
|
+
* generated entry sets to the construct it runs — so the broker's
|
|
29
|
+
* connections are named for the process that holds them, as its database
|
|
30
|
+
* pools are, rather than all being `pgboss`.
|
|
31
|
+
*/
|
|
32
|
+
applicationName?: string;
|
|
8
33
|
}
|
|
9
|
-
declare class PgBossConnection implements EventConnection {
|
|
34
|
+
export declare class PgBossConnection implements EventConnection {
|
|
10
35
|
private config;
|
|
11
36
|
readonly type = EventPublisherType.PgBoss;
|
|
12
37
|
private boss?;
|
|
@@ -26,28 +51,47 @@ declare class PgBossConnection implements EventConnection {
|
|
|
26
51
|
*/
|
|
27
52
|
get instance(): PgBoss | undefined;
|
|
28
53
|
}
|
|
29
|
-
//# sourceMappingURL=PgBossConnection.d.ts.map
|
|
30
54
|
//#endregion
|
|
31
55
|
//#region src/pgboss/PgBossPublisher.d.ts
|
|
32
|
-
|
|
56
|
+
interface PgBossPublisherOptions {
|
|
57
|
+
/**
|
|
58
|
+
* Publishing to a topic: each message is fanned out to every subscriber's
|
|
59
|
+
* own queue rather than inserted into one shared queue. Without it, a
|
|
60
|
+
* message goes to the queue named by its type — a work queue, one consumer.
|
|
61
|
+
*/
|
|
62
|
+
topic?: string;
|
|
63
|
+
}
|
|
64
|
+
/** The pg-boss event a topic's message type is published as. */
|
|
65
|
+
export declare function topicEvent(topic: string, type: string): string;
|
|
66
|
+
export declare class PgBossPublisher<TMessage extends PublishableMessage<string, any>> implements EventPublisher<TMessage> {
|
|
33
67
|
private connection;
|
|
34
|
-
|
|
68
|
+
private options;
|
|
69
|
+
constructor(connection: PgBossConnection, options?: PgBossPublisherOptions);
|
|
35
70
|
/**
|
|
36
71
|
* Create a PgBossPublisher from a connection string.
|
|
37
72
|
* Format: pgboss://user:pass@host:5432/database?schema=pgboss
|
|
38
73
|
*/
|
|
39
|
-
static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionString: string): Promise<PgBossPublisher<TMessage>>;
|
|
74
|
+
static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionString: string, options?: PgBossPublisherOptions): Promise<PgBossPublisher<TMessage>>;
|
|
40
75
|
publish(messages: TMessage[]): Promise<void>;
|
|
41
76
|
close(): Promise<void>;
|
|
42
77
|
}
|
|
43
|
-
//# sourceMappingURL=PgBossPublisher.d.ts.map
|
|
44
78
|
//#endregion
|
|
45
79
|
//#region src/pgboss/PgBossSubscriber.d.ts
|
|
46
80
|
interface PgBossSubscriberOptions {
|
|
47
81
|
batchSize?: number;
|
|
48
82
|
pollingIntervalSeconds?: number;
|
|
83
|
+
/**
|
|
84
|
+
* Subscribing to a topic. Each subscriber then drains a queue of its own,
|
|
85
|
+
* `<topic>/<subscription>`, bound to the events it names — so every
|
|
86
|
+
* subscriber sees every message, and replicas of one subscriber share it.
|
|
87
|
+
* Without it, messages are drained from the queue named by their type:
|
|
88
|
+
* work shared among whoever drains it.
|
|
89
|
+
*/
|
|
90
|
+
topic?: string;
|
|
91
|
+
/** The subscriber's own name on the topic. Required with `topic`. */
|
|
92
|
+
subscription?: string;
|
|
49
93
|
}
|
|
50
|
-
declare class PgBossSubscriber<TMessage extends PublishableMessage<string, any>> implements EventSubscriber<TMessage> {
|
|
94
|
+
export declare class PgBossSubscriber<TMessage extends PublishableMessage<string, any>> implements EventSubscriber<TMessage> {
|
|
51
95
|
private connection;
|
|
52
96
|
private options;
|
|
53
97
|
constructor(connection: PgBossConnection, options?: PgBossSubscriberOptions);
|
|
@@ -58,8 +102,6 @@ declare class PgBossSubscriber<TMessage extends PublishableMessage<string, any>>
|
|
|
58
102
|
static fromConnectionString<TMessage extends PublishableMessage<string, any>>(connectionString: string): Promise<PgBossSubscriber<TMessage>>;
|
|
59
103
|
subscribe(messages: TMessage['type'][], listener: (payload: TMessage) => Promise<void>): Promise<void>;
|
|
60
104
|
}
|
|
61
|
-
//# sourceMappingURL=PgBossSubscriber.d.ts.map
|
|
62
|
-
|
|
63
105
|
//#endregion
|
|
64
|
-
export {
|
|
106
|
+
export type { PgBossConnectionConfig, PgBossPublisherOptions, PgBossSubscriberOptions };
|
|
65
107
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/pgboss/PgBossConnection.ts","../../src/pgboss/PgBossPublisher.ts","../../src/pgboss/PgBossSubscriber.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/pgboss/driver.ts","../../src/pgboss/errors.ts","../../src/pgboss/PgBossConnection.ts","../../src/pgboss/PgBossPublisher.ts","../../src/pgboss/PgBossSubscriber.ts"],"mappings":";;;;;;;;qBAWa,oBAAoB;;;;qBCNpB,yBAAyB;EACrC;;;qBASY,oCAAoC;WAC3B;EAArB,YAAqB;;;;UCZL;EAChB;EACA;;;;;;;EAOA;;qBAGY,4BAA4B;UAKpB;WAJX,OAAI,mBAAA;UACL;UACA;EAER,YAAoB,QAAQ;;;;;SAMf,qBACZ,2BACE,QAAQ;EAgBL,WAAW;EA8BX,SAAS;EAUf;UAIQ;;;;MAQJ,YAAY;;;;UC5FA;;;;;;EAMhB;;;wBAIe,WAAW,eAAe;qBAI7B,gBAAgB,iBAAiB,4CAClC,eAAe;UAGjB;UACA;EAFT,YACS,YAAY,kBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAEjB,0BACA,UAAS,yBACP,QAAQ,gBAAgB;EAOrB,QAAQ,UAAU,aAAa;EAqD/B,SAAS;;;;UC1FC;EAChB;EACA;;;;;;;;EAQA;;EAEA;;qBAGY,iBAAiB,iBAAiB,4CACnC,gBAAgB;UAGlB;UACA;EAFT,YACS,YAAY,kBACZ,UAAS;;;;;SAOL,qBACZ,iBAAiB,iCAChB,2BAA2B,QAAQ,iBAAiB;EAoBhD,UACL,UAAU,oBACV,WAAW,SAAS,aAAa,gBAC/B"}
|