@goatlab/tasks-adapter-bullmq 0.1.0
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/LICENSE +21 -0
- package/dist/BullMQConnector.d.ts +117 -0
- package/dist/BullMQConnector.js +288 -0
- package/dist/BullMQConnector.js.map +1 -0
- package/dist/benchmark.d.ts +12 -0
- package/dist/benchmark.js +349 -0
- package/dist/benchmark.js.map +1 -0
- package/dist/bullmq.spec.d.ts +1 -0
- package/dist/bullmq.spec.js +89 -0
- package/dist/bullmq.spec.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/test/const.d.ts +7 -0
- package/dist/test/const.js +22 -0
- package/dist/test/const.js.map +1 -0
- package/dist/test/redis.d.ts +2 -0
- package/dist/test/redis.js +9 -0
- package/dist/test/redis.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/verify.d.ts +5 -0
- package/dist/verify.js +59 -0
- package/dist/verify.js.map +1 -0
- package/package.json +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) GOAT, SPA. and its affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { ShouldQueue, TaskConnector, TaskStatus } from "@goatlab/tasks-core";
|
|
2
|
+
import type { JobsOptions } from "bullmq";
|
|
3
|
+
import { type Job, Queue, Worker } from "bullmq";
|
|
4
|
+
export interface BullMQConnectionOptions {
|
|
5
|
+
host?: string;
|
|
6
|
+
port?: number;
|
|
7
|
+
password?: string;
|
|
8
|
+
db?: number;
|
|
9
|
+
family?: 4 | 6;
|
|
10
|
+
maxRetriesPerRequest?: number | null;
|
|
11
|
+
}
|
|
12
|
+
export interface BullMQConnectorConfig {
|
|
13
|
+
connection?: BullMQConnectionOptions;
|
|
14
|
+
defaultJobOptions?: JobsOptions;
|
|
15
|
+
}
|
|
16
|
+
export declare class BullMQConnector implements TaskConnector<object> {
|
|
17
|
+
private readonly connectionOptions;
|
|
18
|
+
private readonly defaultJobOptions;
|
|
19
|
+
private readonly queues;
|
|
20
|
+
private readonly workers;
|
|
21
|
+
constructor(config?: BullMQConnectorConfig);
|
|
22
|
+
/**
|
|
23
|
+
* Gets or creates a queue for a given queue name.
|
|
24
|
+
* Queues are memoized to avoid creating multiple instances.
|
|
25
|
+
*/
|
|
26
|
+
getQueue(queueName: string): Queue;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a worker for processing jobs from a BullMQ task.
|
|
29
|
+
* Similar to Hatchet's getHatchetTask but creates a worker.
|
|
30
|
+
*/
|
|
31
|
+
getBullMQWorker(task: ShouldQueue, concurrency?: number): Worker;
|
|
32
|
+
/**
|
|
33
|
+
* Starts a worker to process jobs for the given tasks.
|
|
34
|
+
* Similar pattern to HatchetConnector.startWorker().
|
|
35
|
+
*/
|
|
36
|
+
startWorker({ workerName, tasks, concurrency, }: {
|
|
37
|
+
workerName?: string;
|
|
38
|
+
tasks: ShouldQueue[];
|
|
39
|
+
concurrency?: number;
|
|
40
|
+
}): Promise<Worker[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Stops all workers and closes all queue connections.
|
|
43
|
+
*/
|
|
44
|
+
close(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Gets the status of a job by its ID.
|
|
47
|
+
* Implements the TaskConnector interface.
|
|
48
|
+
* @param id - Job ID (in format: queueName:jobId or just jobId if queueName is known)
|
|
49
|
+
*/
|
|
50
|
+
getStatus(id: string): Promise<TaskStatus>;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the default queue name.
|
|
53
|
+
* Used when no queue name is specified.
|
|
54
|
+
*/
|
|
55
|
+
private getDefaultQueueName;
|
|
56
|
+
/**
|
|
57
|
+
* Queues a task to be run in the background.
|
|
58
|
+
* Implements the TaskConnector interface.
|
|
59
|
+
* @param params
|
|
60
|
+
* @param params.uniqueTaskName - Unique name for this task instance
|
|
61
|
+
* @param params.taskName - Name of the task/queue
|
|
62
|
+
* @param params.postUrl - URL to post the task to (not used in BullMQ, kept for interface compatibility)
|
|
63
|
+
* @param params.taskBody - Body/data of the task
|
|
64
|
+
* @param params.handle - Handler function for the task
|
|
65
|
+
*/
|
|
66
|
+
queue(params: {
|
|
67
|
+
uniqueTaskName: string;
|
|
68
|
+
taskName: string;
|
|
69
|
+
postUrl: string;
|
|
70
|
+
taskBody: object;
|
|
71
|
+
handle: () => Promise<any>;
|
|
72
|
+
}): Promise<Omit<TaskStatus, "payload">>;
|
|
73
|
+
/**
|
|
74
|
+
* Adds a job to a queue with custom options.
|
|
75
|
+
* This is a convenience method for more advanced usage.
|
|
76
|
+
*/
|
|
77
|
+
addJob<T extends object>(queueName: string, jobName: string, data: T, options?: JobsOptions): Promise<Job<T>>;
|
|
78
|
+
/**
|
|
79
|
+
* Gets a job by its ID from a specific queue.
|
|
80
|
+
*/
|
|
81
|
+
getJob<T = any>(queueName: string, jobId: string): Promise<Job<T> | undefined>;
|
|
82
|
+
/**
|
|
83
|
+
* Removes a job by its ID from a specific queue.
|
|
84
|
+
*/
|
|
85
|
+
removeJob(queueName: string, jobId: string): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Pauses a queue.
|
|
88
|
+
*/
|
|
89
|
+
pauseQueue(queueName: string): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Resumes a paused queue.
|
|
92
|
+
*/
|
|
93
|
+
resumeQueue(queueName: string): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Gets the count of jobs in different states for a queue.
|
|
96
|
+
*/
|
|
97
|
+
getJobCounts(queueName: string): Promise<{
|
|
98
|
+
waiting: number;
|
|
99
|
+
active: number;
|
|
100
|
+
completed: number;
|
|
101
|
+
failed: number;
|
|
102
|
+
delayed: number;
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Lists failed jobs in a queue.
|
|
106
|
+
*/
|
|
107
|
+
listFailedJobs(queueName: string, start?: number, end?: number): Promise<Job[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Retries a failed job.
|
|
110
|
+
*/
|
|
111
|
+
retryJob(queueName: string, jobId: string): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Obliterates a queue - removes all jobs and data.
|
|
114
|
+
* Use with caution!
|
|
115
|
+
*/
|
|
116
|
+
obliterateQueue(queueName: string): Promise<void>;
|
|
117
|
+
}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BullMQConnector = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const js_utils_1 = require("@goatlab/js-utils");
|
|
6
|
+
const bullmq_1 = require("bullmq");
|
|
7
|
+
// Default configuration constants
|
|
8
|
+
const DEFAULT_HOST = "localhost";
|
|
9
|
+
const DEFAULT_PORT = 6379;
|
|
10
|
+
const DEFAULT_MAX_RETRIES = 3;
|
|
11
|
+
const DEFAULT_CONCURRENCY = 100;
|
|
12
|
+
/**
|
|
13
|
+
* Maps BullMQ job states to TaskStatusName
|
|
14
|
+
*/
|
|
15
|
+
const mapJobStateToStatus = (state) => {
|
|
16
|
+
switch (state) {
|
|
17
|
+
case "completed":
|
|
18
|
+
return "COMPLETED";
|
|
19
|
+
case "failed":
|
|
20
|
+
return "FAILED";
|
|
21
|
+
case "active":
|
|
22
|
+
return "RUNNING";
|
|
23
|
+
case "waiting":
|
|
24
|
+
case "delayed":
|
|
25
|
+
case "prioritized":
|
|
26
|
+
case "waiting-children":
|
|
27
|
+
return "QUEUED";
|
|
28
|
+
default:
|
|
29
|
+
return "QUEUED";
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
class BullMQConnector {
|
|
33
|
+
connectionOptions;
|
|
34
|
+
defaultJobOptions;
|
|
35
|
+
queues = new Map();
|
|
36
|
+
workers = new Map();
|
|
37
|
+
constructor(config) {
|
|
38
|
+
this.connectionOptions = {
|
|
39
|
+
host: config?.connection?.host || DEFAULT_HOST,
|
|
40
|
+
port: config?.connection?.port || DEFAULT_PORT,
|
|
41
|
+
password: config?.connection?.password,
|
|
42
|
+
db: config?.connection?.db || 0,
|
|
43
|
+
family: config?.connection?.family || 4,
|
|
44
|
+
maxRetriesPerRequest: config?.connection?.maxRetriesPerRequest ?? null,
|
|
45
|
+
};
|
|
46
|
+
this.defaultJobOptions = config?.defaultJobOptions || {
|
|
47
|
+
attempts: DEFAULT_MAX_RETRIES,
|
|
48
|
+
backoff: {
|
|
49
|
+
type: "exponential",
|
|
50
|
+
delay: 1000,
|
|
51
|
+
},
|
|
52
|
+
removeOnComplete: false,
|
|
53
|
+
removeOnFail: false,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Gets or creates a queue for a given queue name.
|
|
58
|
+
* Queues are memoized to avoid creating multiple instances.
|
|
59
|
+
*/
|
|
60
|
+
getQueue(queueName) {
|
|
61
|
+
const existing = this.queues.get(queueName);
|
|
62
|
+
if (existing) {
|
|
63
|
+
return existing;
|
|
64
|
+
}
|
|
65
|
+
const queue = new bullmq_1.Queue(queueName, {
|
|
66
|
+
connection: this.connectionOptions,
|
|
67
|
+
defaultJobOptions: this.defaultJobOptions,
|
|
68
|
+
});
|
|
69
|
+
this.queues.set(queueName, queue);
|
|
70
|
+
return queue;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Creates a worker for processing jobs from a BullMQ task.
|
|
74
|
+
* Similar to Hatchet's getHatchetTask but creates a worker.
|
|
75
|
+
*/
|
|
76
|
+
getBullMQWorker(task, concurrency = DEFAULT_CONCURRENCY) {
|
|
77
|
+
const worker = new bullmq_1.Worker(task.taskName, async (job) => {
|
|
78
|
+
return task.handle(job.data);
|
|
79
|
+
}, {
|
|
80
|
+
connection: this.connectionOptions,
|
|
81
|
+
concurrency,
|
|
82
|
+
});
|
|
83
|
+
return worker;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Starts a worker to process jobs for the given tasks.
|
|
87
|
+
* Similar pattern to HatchetConnector.startWorker().
|
|
88
|
+
*/
|
|
89
|
+
async startWorker({ workerName, tasks, concurrency = DEFAULT_CONCURRENCY, }) {
|
|
90
|
+
const workers = [];
|
|
91
|
+
for (const task of tasks) {
|
|
92
|
+
const worker = new bullmq_1.Worker(task.taskName, async (job) => {
|
|
93
|
+
return task.handle(job.data);
|
|
94
|
+
}, {
|
|
95
|
+
connection: this.connectionOptions,
|
|
96
|
+
concurrency,
|
|
97
|
+
name: `${workerName || task.taskName}-${js_utils_1.Ids.nanoId(5)}`,
|
|
98
|
+
});
|
|
99
|
+
this.workers.set(task.taskName, worker);
|
|
100
|
+
workers.push(worker);
|
|
101
|
+
}
|
|
102
|
+
// Give workers some time to start and connect to Redis
|
|
103
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
104
|
+
return workers;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Stops all workers and closes all queue connections.
|
|
108
|
+
*/
|
|
109
|
+
async close() {
|
|
110
|
+
const closePromises = [];
|
|
111
|
+
for (const worker of this.workers.values()) {
|
|
112
|
+
closePromises.push(worker.close());
|
|
113
|
+
}
|
|
114
|
+
for (const queue of this.queues.values()) {
|
|
115
|
+
closePromises.push(queue.close());
|
|
116
|
+
}
|
|
117
|
+
await Promise.all(closePromises);
|
|
118
|
+
this.workers.clear();
|
|
119
|
+
this.queues.clear();
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Gets the status of a job by its ID.
|
|
123
|
+
* Implements the TaskConnector interface.
|
|
124
|
+
* @param id - Job ID (in format: queueName:jobId or just jobId if queueName is known)
|
|
125
|
+
*/
|
|
126
|
+
async getStatus(id) {
|
|
127
|
+
// Parse the id which may be in format "queueName:jobId"
|
|
128
|
+
const [queueName, jobId] = id.includes(":")
|
|
129
|
+
? id.split(":")
|
|
130
|
+
: [this.getDefaultQueueName(), id];
|
|
131
|
+
const queue = this.getQueue(queueName);
|
|
132
|
+
const job = await queue.getJob(jobId);
|
|
133
|
+
if (!job) {
|
|
134
|
+
// Job not found - could be completed and removed
|
|
135
|
+
return {
|
|
136
|
+
id,
|
|
137
|
+
name: queueName,
|
|
138
|
+
status: "COMPLETED",
|
|
139
|
+
output: "",
|
|
140
|
+
attempts: 0,
|
|
141
|
+
created: new Date().toISOString(),
|
|
142
|
+
nextRun: null,
|
|
143
|
+
nextRunMinutes: null,
|
|
144
|
+
payload: {},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
const state = await job.getState();
|
|
148
|
+
const status = mapJobStateToStatus(state);
|
|
149
|
+
return {
|
|
150
|
+
id,
|
|
151
|
+
name: job.name,
|
|
152
|
+
status,
|
|
153
|
+
output: job.returnvalue ? JSON.stringify(job.returnvalue) : "",
|
|
154
|
+
attempts: job.attemptsMade,
|
|
155
|
+
created: new Date(job.timestamp).toISOString(),
|
|
156
|
+
nextRun: job.processedOn ? new Date(job.processedOn).toISOString() : null,
|
|
157
|
+
nextRunMinutes: null,
|
|
158
|
+
payload: job.data || {},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Gets the default queue name.
|
|
163
|
+
* Used when no queue name is specified.
|
|
164
|
+
*/
|
|
165
|
+
getDefaultQueueName() {
|
|
166
|
+
return "default";
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Queues a task to be run in the background.
|
|
170
|
+
* Implements the TaskConnector interface.
|
|
171
|
+
* @param params
|
|
172
|
+
* @param params.uniqueTaskName - Unique name for this task instance
|
|
173
|
+
* @param params.taskName - Name of the task/queue
|
|
174
|
+
* @param params.postUrl - URL to post the task to (not used in BullMQ, kept for interface compatibility)
|
|
175
|
+
* @param params.taskBody - Body/data of the task
|
|
176
|
+
* @param params.handle - Handler function for the task
|
|
177
|
+
*/
|
|
178
|
+
async queue(params) {
|
|
179
|
+
const queue = this.getQueue(params.taskName);
|
|
180
|
+
// Create a unique job ID using the uniqueTaskName and a nanoId
|
|
181
|
+
const jobId = `${params.uniqueTaskName}_${js_utils_1.Ids.nanoId(5)}`;
|
|
182
|
+
const job = await queue.add(params.taskName, params.taskBody, {
|
|
183
|
+
jobId,
|
|
184
|
+
...this.defaultJobOptions,
|
|
185
|
+
});
|
|
186
|
+
const now = new Date().toISOString();
|
|
187
|
+
return {
|
|
188
|
+
id: `${params.taskName}:${job.id}`,
|
|
189
|
+
name: params.taskName,
|
|
190
|
+
output: "",
|
|
191
|
+
attempts: 0,
|
|
192
|
+
status: "QUEUED",
|
|
193
|
+
created: now,
|
|
194
|
+
nextRun: null,
|
|
195
|
+
nextRunMinutes: null,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Adds a job to a queue with custom options.
|
|
200
|
+
* This is a convenience method for more advanced usage.
|
|
201
|
+
*/
|
|
202
|
+
async addJob(queueName, jobName, data, options) {
|
|
203
|
+
const queue = this.getQueue(queueName);
|
|
204
|
+
return queue.add(jobName, data, {
|
|
205
|
+
...this.defaultJobOptions,
|
|
206
|
+
...options,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Gets a job by its ID from a specific queue.
|
|
211
|
+
*/
|
|
212
|
+
async getJob(queueName, jobId) {
|
|
213
|
+
const queue = this.getQueue(queueName);
|
|
214
|
+
return queue.getJob(jobId);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Removes a job by its ID from a specific queue.
|
|
218
|
+
*/
|
|
219
|
+
async removeJob(queueName, jobId) {
|
|
220
|
+
const queue = this.getQueue(queueName);
|
|
221
|
+
const job = await queue.getJob(jobId);
|
|
222
|
+
if (job) {
|
|
223
|
+
await job.remove();
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Pauses a queue.
|
|
228
|
+
*/
|
|
229
|
+
async pauseQueue(queueName) {
|
|
230
|
+
const queue = this.getQueue(queueName);
|
|
231
|
+
await queue.pause();
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Resumes a paused queue.
|
|
235
|
+
*/
|
|
236
|
+
async resumeQueue(queueName) {
|
|
237
|
+
const queue = this.getQueue(queueName);
|
|
238
|
+
await queue.resume();
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Gets the count of jobs in different states for a queue.
|
|
242
|
+
*/
|
|
243
|
+
async getJobCounts(queueName) {
|
|
244
|
+
const queue = this.getQueue(queueName);
|
|
245
|
+
const counts = await queue.getJobCounts("waiting", "active", "completed", "failed", "delayed");
|
|
246
|
+
return {
|
|
247
|
+
waiting: counts.waiting ?? 0,
|
|
248
|
+
active: counts.active ?? 0,
|
|
249
|
+
completed: counts.completed ?? 0,
|
|
250
|
+
failed: counts.failed ?? 0,
|
|
251
|
+
delayed: counts.delayed ?? 0,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Lists failed jobs in a queue.
|
|
256
|
+
*/
|
|
257
|
+
async listFailedJobs(queueName, start = 0, end = 100) {
|
|
258
|
+
const queue = this.getQueue(queueName);
|
|
259
|
+
return queue.getFailed(start, end);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Retries a failed job.
|
|
263
|
+
*/
|
|
264
|
+
async retryJob(queueName, jobId) {
|
|
265
|
+
const queue = this.getQueue(queueName);
|
|
266
|
+
const job = await queue.getJob(jobId);
|
|
267
|
+
if (job) {
|
|
268
|
+
await job.retry();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Obliterates a queue - removes all jobs and data.
|
|
273
|
+
* Use with caution!
|
|
274
|
+
*/
|
|
275
|
+
async obliterateQueue(queueName) {
|
|
276
|
+
const queue = this.getQueue(queueName);
|
|
277
|
+
await queue.obliterate();
|
|
278
|
+
this.queues.delete(queueName);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
tslib_1.__decorate([
|
|
282
|
+
js_utils_1.Memo.syncMethod(),
|
|
283
|
+
tslib_1.__metadata("design:type", Function),
|
|
284
|
+
tslib_1.__metadata("design:paramtypes", [String]),
|
|
285
|
+
tslib_1.__metadata("design:returntype", bullmq_1.Queue)
|
|
286
|
+
], BullMQConnector.prototype, "getQueue", null);
|
|
287
|
+
exports.BullMQConnector = BullMQConnector;
|
|
288
|
+
//# sourceMappingURL=BullMQConnector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BullMQConnector.js","sourceRoot":"","sources":["../src/BullMQConnector.ts"],"names":[],"mappings":";;;;AAAA,gDAA8C;AAQ9C,mCAAiD;AAEjD,kCAAkC;AAClC,MAAM,Y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AG,GAAG,GAAG;QAET,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACvC,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,SAAiB,EAAE,KAAa;QAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACvC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,GAAG,EAAE;YACR,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;SAClB;IACF,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,eAAe,CAAC,SAAiB;QACtC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACvC,MAAM,KAAK,CAAC,UAAU,EAAE,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;CACD;AA/SA;IAAC,eAAI,CAAC,UAAU,EAAE;;;4CACkB,cAAK;+CAaxC;AA7CF,0CA8UC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BullMQ Benchmark Script
|
|
3
|
+
*
|
|
4
|
+
* Run with: npx tsx src/benchmark.ts [mode]
|
|
5
|
+
*
|
|
6
|
+
* Modes:
|
|
7
|
+
* (default) - Run full benchmark without persistence
|
|
8
|
+
* persist - Compare no-persist vs AOF persistence
|
|
9
|
+
*
|
|
10
|
+
* Uses testcontainers to spin up Redis automatically.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|