@imqueue/job 2.0.2 → 2.0.4
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/index.d.ts +6 -0
- package/index.js +10 -4
- package/package.json +2 -2
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -86,6 +86,9 @@ function toIMQOptions(options, logger) {
|
|
|
86
86
|
safeDeliveryTtl: typeof options.safeLockTtl === 'undefined'
|
|
87
87
|
? 10000 : options.safeLockTtl,
|
|
88
88
|
prefix: options.prefix || 'imq-job',
|
|
89
|
+
verbose: typeof options.verbose === 'undefined'
|
|
90
|
+
? false
|
|
91
|
+
: options.verbose,
|
|
89
92
|
logger,
|
|
90
93
|
};
|
|
91
94
|
}
|
|
@@ -114,7 +117,7 @@ class JobQueuePublisher extends BaseJobQueue {
|
|
|
114
117
|
*/
|
|
115
118
|
push(job, options) {
|
|
116
119
|
options = options || {};
|
|
117
|
-
this.imq.send(this.name, Object.assign(Object.assign({ job: job }, (options.ttl ? { expire: Date.now() + options.ttl } : {})), (options.delay ? { delay: options.delay } : {})), options.delay).catch(err => this.logger.log('JobQueue push error:', err));
|
|
120
|
+
this.imq.send(this.name, Object.assign(Object.assign({ job: job }, (options.ttl ? { expire: Date.now() + options.ttl } : {})), (options.delay ? { delay: options.delay } : {})), options.delay).catch(err => this.logger.log('[JobQueue] push error:', err));
|
|
118
121
|
return this;
|
|
119
122
|
}
|
|
120
123
|
}
|
|
@@ -146,6 +149,9 @@ class JobQueueWorker extends BaseJobQueue {
|
|
|
146
149
|
this.handler = handler;
|
|
147
150
|
this.imq.removeAllListeners('message');
|
|
148
151
|
this.imq.on('message', async (message) => {
|
|
152
|
+
if (typeof message !== 'object' || !message) {
|
|
153
|
+
this.logger.warn('[JobQueue] Invalid message received:', JSON.stringify(message));
|
|
154
|
+
}
|
|
149
155
|
const { job, expire, delay } = message;
|
|
150
156
|
let rescheduleDelay;
|
|
151
157
|
try {
|
|
@@ -160,7 +166,7 @@ class JobQueueWorker extends BaseJobQueue {
|
|
|
160
166
|
}
|
|
161
167
|
catch (err) {
|
|
162
168
|
rescheduleDelay = delay;
|
|
163
|
-
this.logger.log('Error handling job:', err);
|
|
169
|
+
this.logger.log('[JobQueue] Error handling job:', err);
|
|
164
170
|
}
|
|
165
171
|
if (typeof expire === 'number' && expire <= Date.now()) {
|
|
166
172
|
return; // remove job from queue
|
|
@@ -200,7 +206,7 @@ class JobQueue extends BaseJobQueue {
|
|
|
200
206
|
*/
|
|
201
207
|
async start() {
|
|
202
208
|
if (!this.handler) {
|
|
203
|
-
throw new TypeError('Message handler is not set, can not start job queue!');
|
|
209
|
+
throw new TypeError('[JobQueue] Message handler is not set, can not start job queue!');
|
|
204
210
|
}
|
|
205
211
|
return await super.start();
|
|
206
212
|
}
|
|
@@ -214,7 +220,7 @@ class JobQueue extends BaseJobQueue {
|
|
|
214
220
|
*/
|
|
215
221
|
push(job, options) {
|
|
216
222
|
if (!this.handler) {
|
|
217
|
-
throw new TypeError('Message handler is not set, can not enqueue data!');
|
|
223
|
+
throw new TypeError('[JobQueue] Message handler is not set, can not enqueue data!');
|
|
218
224
|
}
|
|
219
225
|
return JobQueuePublisher.prototype.push.call(this, job, options);
|
|
220
226
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imqueue/job",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "Simple job queue",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"message-queue",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"author": "imqueue.com <support@imqueue.com> (https://imqueue.com)",
|
|
37
37
|
"license": "GPL-3.0-only",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@imqueue/core": "^2.0.
|
|
39
|
+
"@imqueue/core": "^2.0.16"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@eslint/eslintrc": "^3.3.1",
|