@joystick.js/node-canary 0.0.0-canary.290 → 0.0.0-canary.292
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.
|
@@ -2,7 +2,10 @@ import getTargetDatabaseProvider from "../../getTargetDatabaseProvider.js";
|
|
|
2
2
|
var queues_default = {
|
|
3
3
|
addJob: function(jobToAdd = {}) {
|
|
4
4
|
const db = this.db?.collection(`queue_${this.queue.name}`);
|
|
5
|
-
return db.insertOne(
|
|
5
|
+
return db.insertOne({
|
|
6
|
+
...jobToAdd,
|
|
7
|
+
attempts: 0
|
|
8
|
+
});
|
|
6
9
|
},
|
|
7
10
|
countJobs: function(status = "") {
|
|
8
11
|
const db = this.db?.collection(`queue_${this.queue.name}`);
|
|
@@ -9,16 +9,18 @@ var queues_default = {
|
|
|
9
9
|
status,
|
|
10
10
|
job,
|
|
11
11
|
payload,
|
|
12
|
-
next_run_at
|
|
12
|
+
next_run_at,
|
|
13
|
+
attempts
|
|
13
14
|
) VALUES (
|
|
14
|
-
$1, $2, $3, $4, $5
|
|
15
|
+
$1, $2, $3, $4, $5, $6
|
|
15
16
|
)
|
|
16
17
|
`, [
|
|
17
18
|
jobToAdd?._id,
|
|
18
19
|
jobToAdd?.status,
|
|
19
20
|
jobToAdd?.job,
|
|
20
21
|
JSON.stringify(jobToAdd?.payload),
|
|
21
|
-
jobToAdd?.nextRunAt
|
|
22
|
+
jobToAdd?.nextRunAt,
|
|
23
|
+
0
|
|
22
24
|
]);
|
|
23
25
|
},
|
|
24
26
|
countJobs: async function(status = "") {
|
package/dist/app/queues/index.js
CHANGED
|
@@ -109,11 +109,19 @@ class Queue {
|
|
|
109
109
|
try {
|
|
110
110
|
if (typeof job_definition?.preflight?.okayToRun === "function") {
|
|
111
111
|
const okay_to_run = await job_definition?.preflight?.okayToRun(nextJob?.payload, nextJob);
|
|
112
|
-
console.log({ okay_to_run, job_id: nextJob?._id });
|
|
113
112
|
if (!okay_to_run) {
|
|
114
113
|
return this._handleRequeueJob(nextJob, timestamps.get_future_time("seconds", job_definition?.preflight?.requeueDelayInSeconds || 10));
|
|
115
114
|
}
|
|
116
115
|
}
|
|
116
|
+
if (!isNaN(job_definition?.maxAttempts)) {
|
|
117
|
+
console.log({
|
|
118
|
+
...nextJob,
|
|
119
|
+
maxAttempts: job_definition?.maxAttempts
|
|
120
|
+
});
|
|
121
|
+
if (nextJob?.attempts >= parseInt(job_definition?.maxAttempts, 10)) {
|
|
122
|
+
return this._handleDeleteJob(nextJob?._id);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
117
125
|
await this._logAttempt(nextJob?._id);
|
|
118
126
|
await job_definition.run(nextJob?.payload, {
|
|
119
127
|
...nextJob,
|