@open-mercato/queue-provider-bullmq 0.0.0-stage → 0.11.1-develop.8983.1.8f477e3f83

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.
@@ -0,0 +1,2 @@
1
+ [build:queue-provider-bullmq] found 3 entry points
2
+ [build:queue-provider-bullmq] built successfully
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
- # Temporary Holding Version
1
+ # Open Mercato BullMQ queue provider
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Configure `QUEUE_STRATEGY=async` and set `QUEUE_REDIS_URL` or `REDIS_URL` to use Redis-backed jobs and retries. `@open-mercato/queue` installs the BullMQ provider for both existing consumers and the default app configuration. The application supplies a supported BullMQ version and can install BullMQ OpenTelemetry support.
4
+
5
+ Existing Redis jobs and the default BullMQ key prefix carry forward without conversion. Explicit connection options override app provider settings. Routing fingerprints include the resolved Redis host, port, database, queue name, and key prefix. Credential rotation does not change the fingerprint.
6
+
7
+ For direct Node.js consumers, the package root exports `createAsyncQueue` and the `queueDriver` descriptor. Application modules should use the queue host.
package/build.mjs ADDED
@@ -0,0 +1,11 @@
1
+ import { dirname } from 'node:path'
2
+ import { fileURLToPath } from 'node:url'
3
+ import { buildPackage } from '../../scripts/build-package.mjs'
4
+
5
+ const packageDir = dirname(fileURLToPath(import.meta.url))
6
+
7
+ await buildPackage(packageDir, {
8
+ name: 'queue-provider-bullmq',
9
+ entryPoints: 'src/**/*.ts',
10
+ target: 'node22',
11
+ })
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ import packageMetadata from "../package.json" with { type: "json" };
2
+ import { __resetPendingProbeBullMQCache, probeAsyncQueue } from "./probe.js";
3
+ import { createAsyncQueue, resolveBullMQResourceIdentity } from "./strategy.js";
4
+ const queueDriver = {
5
+ contractVersion: 1,
6
+ edition: "oss",
7
+ strategy: "async",
8
+ packageVersion: packageMetadata.version,
9
+ createQueue: createAsyncQueue,
10
+ probe: probeAsyncQueue,
11
+ async resourceIdentity(name, options) {
12
+ return resolveBullMQResourceIdentity(name, options?.connection);
13
+ }
14
+ };
15
+ import { resolveBullMQConnection } from "./strategy.js";
16
+ import { ABANDONED_JOB_REASONS, ABANDONED_JOB_SWEEP_INTERVAL_MS, ABANDONED_JOB_DRAIN_TIMEOUT_MS, COMPLETED_RETENTION_COUNT } from "./strategy.js";
17
+ export {
18
+ ABANDONED_JOB_DRAIN_TIMEOUT_MS,
19
+ ABANDONED_JOB_REASONS,
20
+ ABANDONED_JOB_SWEEP_INTERVAL_MS,
21
+ COMPLETED_RETENTION_COUNT,
22
+ __resetPendingProbeBullMQCache,
23
+ createAsyncQueue,
24
+ queueDriver,
25
+ resolveBullMQConnection
26
+ };
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["import packageMetadata from '../package.json' with { type: 'json' }\nimport type { DefaultQueueDriver } from '@open-mercato/queue-provider-kit/default-provider'\nimport { __resetPendingProbeBullMQCache, probeAsyncQueue } from './probe'\nimport { createAsyncQueue, resolveBullMQResourceIdentity } from './strategy'\n\n\nexport const queueDriver: DefaultQueueDriver<'async'> = {\n contractVersion: 1,\n edition: 'oss',\n strategy: 'async',\n packageVersion: packageMetadata.version,\n createQueue: createAsyncQueue,\n probe: probeAsyncQueue,\n async resourceIdentity(name, options) {\n return resolveBullMQResourceIdentity(name, options?.connection)\n },\n}\n\nexport { createAsyncQueue, __resetPendingProbeBullMQCache }\nexport { resolveBullMQConnection } from './strategy'\nexport { ABANDONED_JOB_REASONS, ABANDONED_JOB_SWEEP_INTERVAL_MS, ABANDONED_JOB_DRAIN_TIMEOUT_MS, COMPLETED_RETENTION_COUNT } from './strategy'\n"],
5
+ "mappings": "AAAA,OAAO,qBAAqB,kBAAkB,KAAK,EAAE,MAAM,OAAO;AAElE,SAAS,gCAAgC,uBAAuB;AAChE,SAAS,kBAAkB,qCAAqC;AAGzD,MAAM,cAA2C;AAAA,EACtD,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,UAAU;AAAA,EACV,gBAAgB,gBAAgB;AAAA,EAChC,aAAa;AAAA,EACb,OAAO;AAAA,EACP,MAAM,iBAAiB,MAAM,SAAS;AACpC,WAAO,8BAA8B,MAAM,SAAS,UAAU;AAAA,EAChE;AACF;AAGA,SAAS,+BAA+B;AACxC,SAAS,uBAAuB,iCAAiC,gCAAgC,iCAAiC;",
6
+ "names": []
7
+ }
package/dist/probe.js ADDED
@@ -0,0 +1,61 @@
1
+ import { failedProbe } from "@open-mercato/queue-provider-kit/default-provider";
2
+ let cachedBullMQ;
3
+ async function loadBullMQ() {
4
+ if (cachedBullMQ !== void 0) return cachedBullMQ;
5
+ try {
6
+ cachedBullMQ = await import("bullmq");
7
+ } catch {
8
+ cachedBullMQ = null;
9
+ }
10
+ return cachedBullMQ;
11
+ }
12
+ async function probeAsyncQueue(queueName, options) {
13
+ const bullmq = await loadBullMQ();
14
+ if (!bullmq) {
15
+ return failedProbe(queueName, "async", new Error("bullmq is not installed"));
16
+ }
17
+ const { getRedisUrl, parseRedisUrl } = await import("@open-mercato/shared/lib/redis/connection");
18
+ let connection = options?.connection;
19
+ if (!connection) {
20
+ const url = getRedisUrl("QUEUE");
21
+ if (!url) {
22
+ return failedProbe(queueName, "async", new Error("QUEUE Redis URL is not configured"));
23
+ }
24
+ connection = parseRedisUrl(url);
25
+ } else if (connection.url) {
26
+ connection = parseRedisUrl(connection.url);
27
+ }
28
+ let queue = null;
29
+ try {
30
+ queue = new bullmq.Queue(queueName, { connection });
31
+ const counts = await queue.getJobCounts("waiting", "delayed", "active");
32
+ const waiting = counts.waiting ?? 0;
33
+ const delayed = counts.delayed ?? 0;
34
+ const active = counts.active ?? 0;
35
+ return {
36
+ queueName,
37
+ strategy: "async",
38
+ ready: waiting,
39
+ delayedFuture: delayed,
40
+ active,
41
+ error: false
42
+ };
43
+ } catch (err) {
44
+ return failedProbe(queueName, "async", err);
45
+ } finally {
46
+ if (queue) {
47
+ try {
48
+ await queue.close();
49
+ } catch {
50
+ }
51
+ }
52
+ }
53
+ }
54
+ function __resetPendingProbeBullMQCache() {
55
+ cachedBullMQ = void 0;
56
+ }
57
+ export {
58
+ __resetPendingProbeBullMQCache,
59
+ probeAsyncQueue
60
+ };
61
+ //# sourceMappingURL=probe.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/probe.ts"],
4
+ "sourcesContent": ["import { failedProbe, type QueuePendingProbeOptions, type QueuePendingProbeResult } from '@open-mercato/queue-provider-kit/default-provider'\nimport type { RedisConnectionOptions } from '@open-mercato/queue-provider-kit/types'\n\ntype BullMQModuleShape = {\n Queue: new <T>(name: string, opts: { connection: RedisConnectionOptions }) => {\n getJobCounts: (...states: string[]) => Promise<Record<string, number>>\n close: () => Promise<void>\n }\n}\n\nlet cachedBullMQ: BullMQModuleShape | null | undefined\n\nasync function loadBullMQ(): Promise<BullMQModuleShape | null> {\n if (cachedBullMQ !== undefined) return cachedBullMQ\n try {\n cachedBullMQ = (await import('bullmq')) as unknown as BullMQModuleShape\n } catch {\n cachedBullMQ = null\n }\n return cachedBullMQ\n}\n\nexport async function probeAsyncQueue(\n queueName: string,\n options?: QueuePendingProbeOptions,\n): Promise<QueuePendingProbeResult> {\n const bullmq = await loadBullMQ()\n if (!bullmq) {\n return failedProbe(queueName, 'async', new Error('bullmq is not installed'))\n }\n\n const { getRedisUrl, parseRedisUrl } = await import('@open-mercato/shared/lib/redis/connection')\n let connection = options?.connection\n if (!connection) {\n const url = getRedisUrl('QUEUE')\n if (!url) {\n return failedProbe(queueName, 'async', new Error('QUEUE Redis URL is not configured'))\n }\n connection = parseRedisUrl(url)\n } else if (connection.url) {\n connection = parseRedisUrl(connection.url)\n }\n\n let queue: InstanceType<BullMQModuleShape['Queue']> | null = null\n try {\n queue = new bullmq.Queue(queueName, { connection })\n const counts = await queue.getJobCounts('waiting', 'delayed', 'active')\n const waiting = counts.waiting ?? 0\n const delayed = counts.delayed ?? 0\n const active = counts.active ?? 0\n return {\n queueName,\n strategy: 'async',\n ready: waiting,\n delayedFuture: delayed,\n active,\n error: false,\n }\n } catch (err) {\n return failedProbe(queueName, 'async', err)\n } finally {\n if (queue) {\n try {\n await queue.close()\n } catch {\n /* swallow shutdown errors \u2014 probe must not throw on cleanup */\n }\n }\n }\n}\n\n/** Reset the cached bullmq module reference. Test-only. */\nexport function __resetPendingProbeBullMQCache(): void {\n cachedBullMQ = undefined\n}\n"],
5
+ "mappings": "AAAA,SAAS,mBAAgF;AAUzF,IAAI;AAEJ,eAAe,aAAgD;AAC7D,MAAI,iBAAiB,OAAW,QAAO;AACvC,MAAI;AACF,mBAAgB,MAAM,OAAO,QAAQ;AAAA,EACvC,QAAQ;AACN,mBAAe;AAAA,EACjB;AACA,SAAO;AACT;AAEA,eAAsB,gBACpB,WACA,SACkC;AAClC,QAAM,SAAS,MAAM,WAAW;AAChC,MAAI,CAAC,QAAQ;AACX,WAAO,YAAY,WAAW,SAAS,IAAI,MAAM,yBAAyB,CAAC;AAAA,EAC7E;AAEA,QAAM,EAAE,aAAa,cAAc,IAAI,MAAM,OAAO,2CAA2C;AAC/F,MAAI,aAAa,SAAS;AAC1B,MAAI,CAAC,YAAY;AACf,UAAM,MAAM,YAAY,OAAO;AAC/B,QAAI,CAAC,KAAK;AACR,aAAO,YAAY,WAAW,SAAS,IAAI,MAAM,mCAAmC,CAAC;AAAA,IACvF;AACA,iBAAa,cAAc,GAAG;AAAA,EAChC,WAAW,WAAW,KAAK;AACzB,iBAAa,cAAc,WAAW,GAAG;AAAA,EAC3C;AAEA,MAAI,QAAyD;AAC7D,MAAI;AACF,YAAQ,IAAI,OAAO,MAAM,WAAW,EAAE,WAAW,CAAC;AAClD,UAAM,SAAS,MAAM,MAAM,aAAa,WAAW,WAAW,QAAQ;AACtE,UAAM,UAAU,OAAO,WAAW;AAClC,UAAM,UAAU,OAAO,WAAW;AAClC,UAAM,SAAS,OAAO,UAAU;AAChC,WAAO;AAAA,MACL;AAAA,MACA,UAAU;AAAA,MACV,OAAO;AAAA,MACP,eAAe;AAAA,MACf;AAAA,MACA,OAAO;AAAA,IACT;AAAA,EACF,SAAS,KAAK;AACZ,WAAO,YAAY,WAAW,SAAS,GAAG;AAAA,EAC5C,UAAE;AACA,QAAI,OAAO;AACT,UAAI;AACF,cAAM,MAAM,MAAM;AAAA,MACpB,QAAQ;AAAA,MAER;AAAA,IACF;AAAA,EACF;AACF;AAGO,SAAS,iCAAuC;AACrD,iBAAe;AACjB;",
6
+ "names": []
7
+ }