@holo-js/queue-db 0.1.2 → 0.1.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/dist/index.mjs +18 -2
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -162,6 +162,7 @@ var queueDatabaseInternals = {
|
|
|
162
162
|
// src/drivers/database.ts
|
|
163
163
|
import { randomUUID } from "crypto";
|
|
164
164
|
import { DB } from "@holo-js/db";
|
|
165
|
+
import { connectionAsyncContext } from "@holo-js/db";
|
|
165
166
|
function normalizeDatabaseErrorMessage(error) {
|
|
166
167
|
if (error instanceof Error) {
|
|
167
168
|
return error.message;
|
|
@@ -193,6 +194,13 @@ function normalizeQueueNames(queueNames, fallbackQueueName) {
|
|
|
193
194
|
function createPlaceholders(connection, count, startIndex = 1) {
|
|
194
195
|
return queueDatabaseInternals.createPlaceholderList(connection.getDialect(), count, startIndex).split(", ");
|
|
195
196
|
}
|
|
197
|
+
function resolveDatabaseConnection(name) {
|
|
198
|
+
const active = connectionAsyncContext.getActive()?.connection;
|
|
199
|
+
if (active && active.getConnectionName() === name) {
|
|
200
|
+
return active;
|
|
201
|
+
}
|
|
202
|
+
return DB.connection(name);
|
|
203
|
+
}
|
|
196
204
|
var DatabaseQueueDriver = class {
|
|
197
205
|
constructor(connection, context) {
|
|
198
206
|
this.connection = connection;
|
|
@@ -205,7 +213,7 @@ var DatabaseQueueDriver = class {
|
|
|
205
213
|
mode = "async";
|
|
206
214
|
tableName;
|
|
207
215
|
async getConnection() {
|
|
208
|
-
return queueDatabaseInternals.ensureConnectionReady(
|
|
216
|
+
return queueDatabaseInternals.ensureConnectionReady(resolveDatabaseConnection(this.connection.connection));
|
|
209
217
|
}
|
|
210
218
|
getQuotedTable(connection) {
|
|
211
219
|
return queueDatabaseInternals.quoteIdentifierPath(connection.getDialect(), this.tableName);
|
|
@@ -378,17 +386,25 @@ var databaseQueueDriverInternals = {
|
|
|
378
386
|
// src/failed.ts
|
|
379
387
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
380
388
|
import { DB as DB2 } from "@holo-js/db";
|
|
389
|
+
import { connectionAsyncContext as connectionAsyncContext2 } from "@holo-js/db";
|
|
381
390
|
import { getQueueRuntime } from "@holo-js/queue";
|
|
382
391
|
function getFailedStoreConfig() {
|
|
383
392
|
return getQueueRuntime().config.failed;
|
|
384
393
|
}
|
|
394
|
+
function resolveDatabaseConnection2(name) {
|
|
395
|
+
const active = connectionAsyncContext2.getActive()?.connection;
|
|
396
|
+
if (active && active.getConnectionName() === name) {
|
|
397
|
+
return active;
|
|
398
|
+
}
|
|
399
|
+
return DB2.connection(name);
|
|
400
|
+
}
|
|
385
401
|
async function getFailedStoreConnection() {
|
|
386
402
|
const config = getFailedStoreConfig();
|
|
387
403
|
if (config === false) {
|
|
388
404
|
return null;
|
|
389
405
|
}
|
|
390
406
|
const tableName = queueDatabaseInternals.normalizeIdentifierPath(config.table, "Failed jobs table name");
|
|
391
|
-
const connection = await queueDatabaseInternals.ensureConnectionReady(
|
|
407
|
+
const connection = await queueDatabaseInternals.ensureConnectionReady(resolveDatabaseConnection2(config.connection));
|
|
392
408
|
return {
|
|
393
409
|
connection,
|
|
394
410
|
tableName
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holo-js/queue-db",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Holo-JS Framework - DB-backed integrations for @holo-js/queue",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"test": "vitest --run"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@holo-js/db": "^0.1.
|
|
27
|
-
"@holo-js/queue": "^0.1.
|
|
26
|
+
"@holo-js/db": "^0.1.4",
|
|
27
|
+
"@holo-js/queue": "^0.1.4"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "^22.10.2",
|