@okf/ootils 1.16.0 → 1.17.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/dist/node.d.mts +4 -0
- package/dist/node.d.ts +4 -0
- package/dist/node.js +27 -0
- package/dist/node.mjs +27 -0
- package/package.json +1 -1
package/dist/node.d.mts
CHANGED
|
@@ -1180,6 +1180,10 @@ declare class BaseProducer {
|
|
|
1180
1180
|
execute(params: any): Promise<void>;
|
|
1181
1181
|
addBulkJobs(jobs: any): Promise<bullmq.Job<any, any, string>[]>;
|
|
1182
1182
|
addJob(name: any, data: any, opts?: {}): Promise<bullmq.Job<any, any, string>>;
|
|
1183
|
+
removeJobs(jobIds: any): Promise<{
|
|
1184
|
+
removed: number;
|
|
1185
|
+
results: any[];
|
|
1186
|
+
}>;
|
|
1183
1187
|
getStatus(): Promise<{
|
|
1184
1188
|
waiting: number;
|
|
1185
1189
|
active: number;
|
package/dist/node.d.ts
CHANGED
|
@@ -1180,6 +1180,10 @@ declare class BaseProducer {
|
|
|
1180
1180
|
execute(params: any): Promise<void>;
|
|
1181
1181
|
addBulkJobs(jobs: any): Promise<bullmq.Job<any, any, string>[]>;
|
|
1182
1182
|
addJob(name: any, data: any, opts?: {}): Promise<bullmq.Job<any, any, string>>;
|
|
1183
|
+
removeJobs(jobIds: any): Promise<{
|
|
1184
|
+
removed: number;
|
|
1185
|
+
results: any[];
|
|
1186
|
+
}>;
|
|
1183
1187
|
getStatus(): Promise<{
|
|
1184
1188
|
waiting: number;
|
|
1185
1189
|
active: number;
|
package/dist/node.js
CHANGED
|
@@ -1328,6 +1328,33 @@ var require_BaseProducer = __commonJS({
|
|
|
1328
1328
|
throw error;
|
|
1329
1329
|
}
|
|
1330
1330
|
}
|
|
1331
|
+
async removeJobs(jobIds) {
|
|
1332
|
+
if (!jobIds || jobIds.length === 0) {
|
|
1333
|
+
return { removed: 0, results: [] };
|
|
1334
|
+
}
|
|
1335
|
+
try {
|
|
1336
|
+
const results = await Promise.all(
|
|
1337
|
+
jobIds.map(async (jobId) => {
|
|
1338
|
+
try {
|
|
1339
|
+
const job = await this.queue.getJob(jobId);
|
|
1340
|
+
if (job) {
|
|
1341
|
+
await job.remove();
|
|
1342
|
+
return { jobId, removed: true };
|
|
1343
|
+
}
|
|
1344
|
+
return { jobId, removed: false, reason: "not found" };
|
|
1345
|
+
} catch (err) {
|
|
1346
|
+
return { jobId, removed: false, reason: err.message };
|
|
1347
|
+
}
|
|
1348
|
+
})
|
|
1349
|
+
);
|
|
1350
|
+
const removedCount = results.filter((r) => r.removed).length;
|
|
1351
|
+
console.log(`\u{1F5D1}\uFE0F ${this.constructor.name}: Removed ${removedCount}/${jobIds.length} jobs`);
|
|
1352
|
+
return { removed: removedCount, results };
|
|
1353
|
+
} catch (error) {
|
|
1354
|
+
console.error(`\u274C ${this.constructor.name}: Failed to remove jobs:`, error);
|
|
1355
|
+
throw error;
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1331
1358
|
async getStatus() {
|
|
1332
1359
|
const waiting = await this.queue.getWaiting();
|
|
1333
1360
|
const active = await this.queue.getActive();
|
package/dist/node.mjs
CHANGED
|
@@ -1333,6 +1333,33 @@ var require_BaseProducer = __commonJS({
|
|
|
1333
1333
|
throw error;
|
|
1334
1334
|
}
|
|
1335
1335
|
}
|
|
1336
|
+
async removeJobs(jobIds) {
|
|
1337
|
+
if (!jobIds || jobIds.length === 0) {
|
|
1338
|
+
return { removed: 0, results: [] };
|
|
1339
|
+
}
|
|
1340
|
+
try {
|
|
1341
|
+
const results = await Promise.all(
|
|
1342
|
+
jobIds.map(async (jobId) => {
|
|
1343
|
+
try {
|
|
1344
|
+
const job = await this.queue.getJob(jobId);
|
|
1345
|
+
if (job) {
|
|
1346
|
+
await job.remove();
|
|
1347
|
+
return { jobId, removed: true };
|
|
1348
|
+
}
|
|
1349
|
+
return { jobId, removed: false, reason: "not found" };
|
|
1350
|
+
} catch (err) {
|
|
1351
|
+
return { jobId, removed: false, reason: err.message };
|
|
1352
|
+
}
|
|
1353
|
+
})
|
|
1354
|
+
);
|
|
1355
|
+
const removedCount = results.filter((r) => r.removed).length;
|
|
1356
|
+
console.log(`\u{1F5D1}\uFE0F ${this.constructor.name}: Removed ${removedCount}/${jobIds.length} jobs`);
|
|
1357
|
+
return { removed: removedCount, results };
|
|
1358
|
+
} catch (error) {
|
|
1359
|
+
console.error(`\u274C ${this.constructor.name}: Failed to remove jobs:`, error);
|
|
1360
|
+
throw error;
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1336
1363
|
async getStatus() {
|
|
1337
1364
|
const waiting = await this.queue.getWaiting();
|
|
1338
1365
|
const active = await this.queue.getActive();
|