@abtnode/queue 1.16.17-beta-1cab4b42 → 1.16.17-beta-ce49fe0e
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/lib/index.js +19 -2
- package/package.json +4 -4
package/lib/index.js
CHANGED
|
@@ -16,7 +16,7 @@ const MIN_DELAY = process.env.NODE_ENV === 'test' ? 2 : 5;
|
|
|
16
16
|
*
|
|
17
17
|
* @param {Object} config
|
|
18
18
|
* @param {string} [config.file] filepath of JobStore
|
|
19
|
-
* @param {
|
|
19
|
+
* @param {import('@abtnode/queue/lib/store/sequelize')} [config.store] queue store instance
|
|
20
20
|
* @param {function} config.onJob called on receives job
|
|
21
21
|
* @param {Object} [config.options] options
|
|
22
22
|
* @param {string} [config.options.id] id of the job
|
|
@@ -105,7 +105,7 @@ module.exports = function createQueue({ file, store, onJob, options = {} }) {
|
|
|
105
105
|
) {
|
|
106
106
|
[{ job, jobId, persist = true, delay }] = args;
|
|
107
107
|
} else {
|
|
108
|
-
[job, jobId, persist = true] = args;
|
|
108
|
+
[job, jobId, persist = true, delay] = args;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
const events = new EventEmitter();
|
|
@@ -219,6 +219,22 @@ module.exports = function createQueue({ file, store, onJob, options = {} }) {
|
|
|
219
219
|
return doc ? doc.job : null;
|
|
220
220
|
};
|
|
221
221
|
|
|
222
|
+
/**
|
|
223
|
+
*
|
|
224
|
+
* @param {string} id
|
|
225
|
+
*/
|
|
226
|
+
const deleteJob = async (id) => {
|
|
227
|
+
const exists = await getJob(id);
|
|
228
|
+
|
|
229
|
+
if (exists) {
|
|
230
|
+
await cancel(id);
|
|
231
|
+
await store.deleteJob(id);
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return false;
|
|
236
|
+
};
|
|
237
|
+
|
|
222
238
|
// Populate the queue on startup
|
|
223
239
|
store.loadDatabase(async (err) => {
|
|
224
240
|
if (err) {
|
|
@@ -278,6 +294,7 @@ module.exports = function createQueue({ file, store, onJob, options = {} }) {
|
|
|
278
294
|
error: (cb) => (queue.error = cb),
|
|
279
295
|
get: getJob,
|
|
280
296
|
cancel,
|
|
297
|
+
delete: deleteJob,
|
|
281
298
|
options: {
|
|
282
299
|
concurrency,
|
|
283
300
|
maxRetries,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.17-beta-
|
|
6
|
+
"version": "1.16.17-beta-ce49fe0e",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/db": "1.16.17-beta-
|
|
23
|
-
"@abtnode/util": "1.16.17-beta-
|
|
22
|
+
"@abtnode/db": "1.16.17-beta-ce49fe0e",
|
|
23
|
+
"@abtnode/util": "1.16.17-beta-ce49fe0e",
|
|
24
24
|
"debug": "^4.3.4",
|
|
25
25
|
"fastq": "^1.13.0",
|
|
26
26
|
"uuid": "^8.3.2"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "d8a04ff2ef9cd52a02d019bc2c9a743785e869c3",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"jest": "^27.5.1"
|
|
31
31
|
}
|