@motiadev/adapter-bullmq-events 0.14.0-beta.165-912190 → 0.14.0-beta.165-557689

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.
@@ -1,5 +1,5 @@
1
1
  //#region src/constants.ts
2
- const DEFAULT_CONCURRENCY = 5;
2
+ const DEFAULT_CONCURRENCY = 10;
3
3
  const DEFAULT_ATTEMPTS = 3;
4
4
  const DEFAULT_BACKOFF_DELAY = 2e3;
5
5
  const DEFAULT_REMOVE_ON_COMPLETE_COUNT = 1e3;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.mjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const DEFAULT_CONCURRENCY = 5\nexport const DEFAULT_ATTEMPTS = 3\nexport const DEFAULT_BACKOFF_DELAY = 2000\nexport const DEFAULT_REMOVE_ON_COMPLETE_COUNT = 1000\nexport const DEFAULT_REMOVE_ON_FAIL_COUNT = 5000\nexport const DEFAULT_PREFIX = 'motia'\nexport const FIFO_CONCURRENCY = 1\nexport const MILLISECONDS_PER_SECOND = 1000\nexport const SECONDS_PER_DAY = 86400\nexport const DEFAULT_DLQ_TTL = 30 * SECONDS_PER_DAY\nexport const DEFAULT_DLQ_SUFFIX = '.dlq'\nexport const DLQ_JOB_PREFIX = 'dlq-'\n\nexport const LOG_PREFIX = '[BullMQ]'\n"],"mappings":";AAAA,MAAa,sBAAsB;AACnC,MAAa,mBAAmB;AAChC,MAAa,wBAAwB;AACrC,MAAa,mCAAmC;AAChD,MAAa,+BAA+B;AAC5C,MAAa,iBAAiB;AAC9B,MAAa,mBAAmB;AAChC,MAAa,0BAA0B;AACvC,MAAa,kBAAkB;AAC/B,MAAa,kBAAkB,KAAK;AACpC,MAAa,qBAAqB;AAClC,MAAa,iBAAiB;AAE9B,MAAa,aAAa"}
1
+ {"version":3,"file":"constants.mjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const DEFAULT_CONCURRENCY = 10\nexport const DEFAULT_ATTEMPTS = 3\nexport const DEFAULT_BACKOFF_DELAY = 2000\nexport const DEFAULT_REMOVE_ON_COMPLETE_COUNT = 1000\nexport const DEFAULT_REMOVE_ON_FAIL_COUNT = 5000\nexport const DEFAULT_PREFIX = 'motia'\nexport const FIFO_CONCURRENCY = 1\nexport const MILLISECONDS_PER_SECOND = 1000\nexport const SECONDS_PER_DAY = 86400\nexport const DEFAULT_DLQ_TTL = 30 * SECONDS_PER_DAY\nexport const DEFAULT_DLQ_SUFFIX = '.dlq'\nexport const DLQ_JOB_PREFIX = 'dlq-'\n\nexport const LOG_PREFIX = '[BullMQ]'\n"],"mappings":";AAAA,MAAa,sBAAsB;AACnC,MAAa,mBAAmB;AAChC,MAAa,wBAAwB;AACrC,MAAa,mCAAmC;AAChD,MAAa,+BAA+B;AAC5C,MAAa,iBAAiB;AAC9B,MAAa,mBAAmB;AAChC,MAAa,0BAA0B;AACvC,MAAa,kBAAkB;AAC/B,MAAa,kBAAkB,KAAK;AACpC,MAAa,qBAAqB;AAClC,MAAa,iBAAiB;AAE9B,MAAa,aAAa"}
@@ -17,7 +17,7 @@ var WorkerManager = class {
17
17
  const id = v4();
18
18
  const queueName = this.getQueueName(topic, stepName);
19
19
  this.addTopicSubscription(topic, id);
20
- const concurrency = options?.type === "fifo" ? FIFO_CONCURRENCY : this.config.concurrency;
20
+ const concurrency = options?.type === "fifo" ? FIFO_CONCURRENCY : options?.concurrency || this.config.concurrency;
21
21
  const attempts = options?.maxRetries != null ? options.maxRetries + 1 : this.config.defaultJobOptions.attempts;
22
22
  const lockDuration = options?.visibilityTimeout ? options.visibilityTimeout * MILLISECONDS_PER_SECOND : void 0;
23
23
  const worker = new Worker(queueName, async (job) => {
@@ -1 +1 @@
1
- {"version":3,"file":"worker-manager.mjs","names":["uuidv4","handle: SubscriptionHandle","workerInfo: WorkerInfo"],"sources":["../src/worker-manager.ts"],"sourcesContent":["import type { Event, QueueConfig, SubscriptionHandle } from '@motiadev/core'\nimport { type Job, Worker } from 'bullmq'\nimport type { Redis } from 'ioredis'\nimport { v4 as uuidv4 } from 'uuid'\nimport type { MergedConfig } from './config-builder'\nimport { FIFO_CONCURRENCY, MILLISECONDS_PER_SECOND } from './constants'\nimport type { DLQManager } from './dlq-manager'\nimport { WorkerCreationError } from './errors'\n\nexport type SubscriberInfo = {\n topic: string\n stepName: string\n queueConfig?: QueueConfig\n}\n\ntype WorkerInfo = {\n worker: Worker\n topic: string\n stepName: string\n handle: SubscriptionHandle\n queueConfig?: QueueConfig\n}\n\ntype JobData<TData> = {\n topic: string\n data: TData\n traceId: string\n flows?: string[]\n messageGroupId?: string\n}\n\nexport class WorkerManager {\n private readonly workers: Map<string, WorkerInfo> = new Map()\n private readonly topicSubscriptions: Map<string, Set<string>> = new Map()\n private readonly connection: Redis\n private readonly config: MergedConfig\n private readonly getQueueName: (topic: string, stepName: string) => string\n private readonly dlqManager: DLQManager | null\n\n constructor(\n connection: Redis,\n config: MergedConfig,\n getQueueName: (topic: string, stepName: string) => string,\n dlqManager?: DLQManager,\n ) {\n this.connection = connection\n this.config = config\n this.getQueueName = getQueueName\n this.dlqManager = dlqManager ?? null\n }\n\n createWorker<TData>(\n topic: string,\n stepName: string,\n handler: (event: Event<TData>) => void | Promise<void>,\n options?: QueueConfig,\n ): SubscriptionHandle {\n const id = uuidv4()\n const queueName = this.getQueueName(topic, stepName)\n\n this.addTopicSubscription(topic, id)\n\n const concurrency = options?.type === 'fifo' ? FIFO_CONCURRENCY : this.config.concurrency\n const attempts = options?.maxRetries != null ? options.maxRetries + 1 : this.config.defaultJobOptions.attempts\n const lockDuration = options?.visibilityTimeout ? options.visibilityTimeout * MILLISECONDS_PER_SECOND : undefined\n\n const worker = new Worker(\n queueName,\n async (job: Job<JobData<TData>>) => {\n const eventData = job.data\n const event = {\n topic: eventData.topic,\n data: eventData.data,\n traceId: eventData.traceId,\n flows: eventData.flows,\n messageGroupId: eventData.messageGroupId,\n } as Event<TData>\n await handler(event)\n },\n {\n connection: this.connection,\n prefix: this.config.prefix,\n concurrency,\n lockDuration,\n removeOnComplete: this.config.defaultJobOptions.removeOnComplete,\n removeOnFail: this.config.defaultJobOptions.removeOnFail,\n },\n )\n\n this.setupWorkerHandlers(worker, topic, stepName, attempts ?? 3)\n\n const handle: SubscriptionHandle = {\n topic,\n id,\n unsubscribe: async () => {\n await this.removeWorker(handle.id)\n },\n }\n\n const workerInfo: WorkerInfo = {\n worker,\n topic,\n stepName,\n handle,\n queueConfig: options,\n }\n\n this.workers.set(id, workerInfo)\n return handle\n }\n\n getSubscribers(topic: string): SubscriberInfo[] {\n const subscriptionIds = this.topicSubscriptions.get(topic)\n if (!subscriptionIds || subscriptionIds.size === 0) {\n return []\n }\n\n return Array.from(subscriptionIds)\n .map((id) => this.workers.get(id))\n .filter((info): info is WorkerInfo => info !== undefined)\n .map((info) => ({ topic: info.topic, stepName: info.stepName, queueConfig: info.queueConfig }))\n }\n\n getWorkerInfo(id: string): WorkerInfo | undefined {\n return this.workers.get(id)\n }\n\n async removeWorker(id: string): Promise<void> {\n const workerInfo = this.workers.get(id)\n if (!workerInfo) {\n return\n }\n\n this.removeTopicSubscription(workerInfo.topic, id)\n await workerInfo.worker.close()\n this.workers.delete(id)\n }\n\n async closeAll(): Promise<void> {\n const promises = Array.from(this.workers.values()).map((info) =>\n info.worker.close().catch((err) => {\n console.error(`[BullMQ] Error closing worker for topic ${info.topic}, step ${info.stepName}:`, err)\n }),\n )\n await Promise.allSettled(promises)\n this.workers.clear()\n this.topicSubscriptions.clear()\n }\n\n getSubscriptionCount(topic: string): number {\n return Array.from(this.workers.values()).filter((w) => w.topic === topic).length\n }\n\n listTopics(): string[] {\n return Array.from(new Set(Array.from(this.workers.values()).map((w) => w.topic)))\n }\n\n private addTopicSubscription(topic: string, id: string): void {\n if (!this.topicSubscriptions.has(topic)) {\n this.topicSubscriptions.set(topic, new Set())\n }\n this.topicSubscriptions.get(topic)?.add(id)\n }\n\n private removeTopicSubscription(topic: string, id: string): void {\n const subscriptions = this.topicSubscriptions.get(topic)\n if (subscriptions) {\n subscriptions.delete(id)\n if (subscriptions.size === 0) {\n this.topicSubscriptions.delete(topic)\n }\n }\n }\n\n private setupWorkerHandlers(worker: Worker, topic: string, stepName: string, attempts: number): void {\n worker.on('error', (err: Error) => {\n const error = new WorkerCreationError(topic, stepName, err)\n console.error(`[BullMQ] Worker error for topic ${topic}, step ${stepName}:`, error)\n })\n worker.on('failed', async (job: Job<JobData<unknown>> | undefined, err: Error) => {\n if (job) {\n const attemptsMade = job.attemptsMade || 0\n if (attemptsMade >= attempts) {\n if (this.dlqManager) {\n const eventData = job.data\n const event = {\n topic: eventData.topic || topic,\n data: eventData.data,\n traceId: eventData.traceId || 'unknown',\n ...(eventData.flows && { flows: eventData.flows }),\n ...(eventData.messageGroupId && { messageGroupId: eventData.messageGroupId }),\n } as Event<unknown>\n\n await this.dlqManager.moveToDLQ(topic, stepName, event, err, attemptsMade, job.id)\n }\n }\n }\n })\n }\n}\n"],"mappings":";;;;;;AA+BA,IAAa,gBAAb,MAA2B;CAQzB,YACE,YACA,QACA,cACA,YACA;iCAZkD,IAAI,KAAK;4CACG,IAAI,KAAK;AAYvE,OAAK,aAAa;AAClB,OAAK,SAAS;AACd,OAAK,eAAe;AACpB,OAAK,aAAa,cAAc;;CAGlC,aACE,OACA,UACA,SACA,SACoB;EACpB,MAAM,KAAKA,IAAQ;EACnB,MAAM,YAAY,KAAK,aAAa,OAAO,SAAS;AAEpD,OAAK,qBAAqB,OAAO,GAAG;EAEpC,MAAM,cAAc,SAAS,SAAS,SAAS,mBAAmB,KAAK,OAAO;EAC9E,MAAM,WAAW,SAAS,cAAc,OAAO,QAAQ,aAAa,IAAI,KAAK,OAAO,kBAAkB;EACtG,MAAM,eAAe,SAAS,oBAAoB,QAAQ,oBAAoB,0BAA0B;EAExG,MAAM,SAAS,IAAI,OACjB,WACA,OAAO,QAA6B;GAClC,MAAM,YAAY,IAAI;AAQtB,SAAM,QAPQ;IACZ,OAAO,UAA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,UAAU,OAAO;OACjD,GAAI,UAAU,kBAAkB,EAAE,gBAAgB,UAAU,gBAAgB;OAC7E;AAED,YAAM,KAAK,WAAW,UAAU,OAAO,UAAU,OAAO,KAAK,cAAc,IAAI,GAAG;;;;IAIxF"}
1
+ {"version":3,"file":"worker-manager.mjs","names":["uuidv4","handle: SubscriptionHandle","workerInfo: WorkerInfo"],"sources":["../src/worker-manager.ts"],"sourcesContent":["import type { Event, QueueConfig, SubscriptionHandle } from '@motiadev/core'\nimport { type Job, Worker } from 'bullmq'\nimport type { Redis } from 'ioredis'\nimport { v4 as uuidv4 } from 'uuid'\nimport type { MergedConfig } from './config-builder'\nimport { FIFO_CONCURRENCY, MILLISECONDS_PER_SECOND } from './constants'\nimport type { DLQManager } from './dlq-manager'\nimport { WorkerCreationError } from './errors'\n\nexport type SubscriberInfo = {\n topic: string\n stepName: string\n queueConfig?: QueueConfig\n}\n\ntype WorkerInfo = {\n worker: Worker\n topic: string\n stepName: string\n handle: SubscriptionHandle\n queueConfig?: QueueConfig\n}\n\ntype JobData<TData> = {\n topic: string\n data: TData\n traceId: string\n flows?: string[]\n messageGroupId?: string\n}\n\nexport class WorkerManager {\n private readonly workers: Map<string, WorkerInfo> = new Map()\n private readonly topicSubscriptions: Map<string, Set<string>> = new Map()\n private readonly connection: Redis\n private readonly config: MergedConfig\n private readonly getQueueName: (topic: string, stepName: string) => string\n private readonly dlqManager: DLQManager | null\n\n constructor(\n connection: Redis,\n config: MergedConfig,\n getQueueName: (topic: string, stepName: string) => string,\n dlqManager?: DLQManager,\n ) {\n this.connection = connection\n this.config = config\n this.getQueueName = getQueueName\n this.dlqManager = dlqManager ?? null\n }\n\n createWorker<TData>(\n topic: string,\n stepName: string,\n handler: (event: Event<TData>) => void | Promise<void>,\n options?: QueueConfig,\n ): SubscriptionHandle {\n const id = uuidv4()\n const queueName = this.getQueueName(topic, stepName)\n\n this.addTopicSubscription(topic, id)\n\n const concurrency = options?.type === 'fifo' ? FIFO_CONCURRENCY : options?.concurrency || this.config.concurrency\n const attempts = options?.maxRetries != null ? options.maxRetries + 1 : this.config.defaultJobOptions.attempts\n const lockDuration = options?.visibilityTimeout ? options.visibilityTimeout * MILLISECONDS_PER_SECOND : undefined\n\n const worker = new Worker(\n queueName,\n async (job: Job<JobData<TData>>) => {\n const eventData = job.data\n const event = {\n topic: eventData.topic,\n data: eventData.data,\n traceId: eventData.traceId,\n flows: eventData.flows,\n messageGroupId: eventData.messageGroupId,\n } as Event<TData>\n await handler(event)\n },\n {\n connection: this.connection,\n prefix: this.config.prefix,\n concurrency,\n lockDuration,\n removeOnComplete: this.config.defaultJobOptions.removeOnComplete,\n removeOnFail: this.config.defaultJobOptions.removeOnFail,\n },\n )\n\n this.setupWorkerHandlers(worker, topic, stepName, attempts ?? 3)\n\n const handle: SubscriptionHandle = {\n topic,\n id,\n unsubscribe: async () => {\n await this.removeWorker(handle.id)\n },\n }\n\n const workerInfo: WorkerInfo = {\n worker,\n topic,\n stepName,\n handle,\n queueConfig: options,\n }\n\n this.workers.set(id, workerInfo)\n return handle\n }\n\n getSubscribers(topic: string): SubscriberInfo[] {\n const subscriptionIds = this.topicSubscriptions.get(topic)\n if (!subscriptionIds || subscriptionIds.size === 0) {\n return []\n }\n\n return Array.from(subscriptionIds)\n .map((id) => this.workers.get(id))\n .filter((info): info is WorkerInfo => info !== undefined)\n .map((info) => ({ topic: info.topic, stepName: info.stepName, queueConfig: info.queueConfig }))\n }\n\n getWorkerInfo(id: string): WorkerInfo | undefined {\n return this.workers.get(id)\n }\n\n async removeWorker(id: string): Promise<void> {\n const workerInfo = this.workers.get(id)\n if (!workerInfo) {\n return\n }\n\n this.removeTopicSubscription(workerInfo.topic, id)\n await workerInfo.worker.close()\n this.workers.delete(id)\n }\n\n async closeAll(): Promise<void> {\n const promises = Array.from(this.workers.values()).map((info) =>\n info.worker.close().catch((err) => {\n console.error(`[BullMQ] Error closing worker for topic ${info.topic}, step ${info.stepName}:`, err)\n }),\n )\n await Promise.allSettled(promises)\n this.workers.clear()\n this.topicSubscriptions.clear()\n }\n\n getSubscriptionCount(topic: string): number {\n return Array.from(this.workers.values()).filter((w) => w.topic === topic).length\n }\n\n listTopics(): string[] {\n return Array.from(new Set(Array.from(this.workers.values()).map((w) => w.topic)))\n }\n\n private addTopicSubscription(topic: string, id: string): void {\n if (!this.topicSubscriptions.has(topic)) {\n this.topicSubscriptions.set(topic, new Set())\n }\n this.topicSubscriptions.get(topic)?.add(id)\n }\n\n private removeTopicSubscription(topic: string, id: string): void {\n const subscriptions = this.topicSubscriptions.get(topic)\n if (subscriptions) {\n subscriptions.delete(id)\n if (subscriptions.size === 0) {\n this.topicSubscriptions.delete(topic)\n }\n }\n }\n\n private setupWorkerHandlers(worker: Worker, topic: string, stepName: string, attempts: number): void {\n worker.on('error', (err: Error) => {\n const error = new WorkerCreationError(topic, stepName, err)\n console.error(`[BullMQ] Worker error for topic ${topic}, step ${stepName}:`, error)\n })\n worker.on('failed', async (job: Job<JobData<unknown>> | undefined, err: Error) => {\n if (job) {\n const attemptsMade = job.attemptsMade || 0\n if (attemptsMade >= attempts) {\n if (this.dlqManager) {\n const eventData = job.data\n const event = {\n topic: eventData.topic || topic,\n data: eventData.data,\n traceId: eventData.traceId || 'unknown',\n ...(eventData.flows && { flows: eventData.flows }),\n ...(eventData.messageGroupId && { messageGroupId: eventData.messageGroupId }),\n } as Event<unknown>\n\n await this.dlqManager.moveToDLQ(topic, stepName, event, err, attemptsMade, job.id)\n }\n }\n }\n })\n }\n}\n"],"mappings":";;;;;;AA+BA,IAAa,gBAAb,MAA2B;CAQzB,YACE,YACA,QACA,cACA,YACA;iCAZkD,IAAI,KAAK;4CACG,IAAI,KAAK;AAYvE,OAAK,aAAa;AAClB,OAAK,SAAS;AACd,OAAK,eAAe;AACpB,OAAK,aAAa,cAAc;;CAGlC,aACE,OACA,UACA,SACA,SACoB;EACpB,MAAM,KAAKA,IAAQ;EACnB,MAAM,YAAY,KAAK,aAAa,OAAO,SAAS;AAE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WAAQ,MAAM,mCAAmC,MAAM,SAAS,SAAS,IAAI,MAAM;IACnF;AACF,SAAO,GAAG,UAAU,OAAO,KAAwC,QAAe;AAChF,OAAI,KAAK;IACP,MAAM,eAAe,IAAI,gBAAgB;AACzC,QAAI,gBAAgB,UAClB;SAAI,KAAK,YAAY;MACnB,MAAM,YAAY,IAAI;MACtB,MAAM,QAAQ;OACZ,OAAO,UAAU,SAAS;OAC1B,MAAM,UAAU;OAChB,SAAS,UAAU,WAAW;OAC9B,GAAI,UAAU,SAAS,EAAE,OAAO,UAAU,OAAO;OACjD,GAAI,UAAU,kBAAkB,EAAE,gBAAgB,UAAU,gBAAgB;OAC7E;AAED,YAAM,KAAK,WAAW,UAAU,OAAO,UAAU,OAAO,KAAK,cAAc,IAAI,GAAG;;;;IAIxF"}
package/package.json CHANGED
@@ -5,12 +5,12 @@
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.mts",
8
- "version": "0.14.0-beta.165-912190",
8
+ "version": "0.14.0-beta.165-557689",
9
9
  "dependencies": {
10
10
  "bullmq": "^5.63.0",
11
11
  "ioredis": "^5.8.2",
12
12
  "uuid": "^11.1.0",
13
- "@motiadev/core": "0.14.0-beta.165-912190"
13
+ "@motiadev/core": "0.14.0-beta.165-557689"
14
14
  },
15
15
  "devDependencies": {
16
16
  "rimraf": "^6.0.1",
package/src/constants.ts CHANGED
@@ -1,4 +1,4 @@
1
- export const DEFAULT_CONCURRENCY = 5
1
+ export const DEFAULT_CONCURRENCY = 10
2
2
  export const DEFAULT_ATTEMPTS = 3
3
3
  export const DEFAULT_BACKOFF_DELAY = 2000
4
4
  export const DEFAULT_REMOVE_ON_COMPLETE_COUNT = 1000
@@ -60,7 +60,7 @@ export class WorkerManager {
60
60
 
61
61
  this.addTopicSubscription(topic, id)
62
62
 
63
- const concurrency = options?.type === 'fifo' ? FIFO_CONCURRENCY : this.config.concurrency
63
+ const concurrency = options?.type === 'fifo' ? FIFO_CONCURRENCY : options?.concurrency || this.config.concurrency
64
64
  const attempts = options?.maxRetries != null ? options.maxRetries + 1 : this.config.defaultJobOptions.attempts
65
65
  const lockDuration = options?.visibilityTimeout ? options.visibilityTimeout * MILLISECONDS_PER_SECOND : undefined
66
66