Skip to content

Commit 29bac85

Browse files
harryadelBastienRodz
authored andcommitted
Push latest changes
1 parent 022cb75 commit 29bac85

File tree

7 files changed

+29
-24
lines changed

7 files changed

+29
-24
lines changed

server/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Jobs.execute = async function (jobId, callback, force) {
188188
// 3. Ensure the job is real
189189

190190
if (Operator.manager.isAvailable(doc.name) || force) {
191-
return Actions.execute(doc, callback, force)
191+
return await Actions.execute(doc, callback, force)
192192
} else {
193193
Utilities.logger("Unable to execute job - queue is busy: " + doc.name + "/" + jobId);
194194
return false;

server/imports/operator/manager/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ manager.add = function (name) {
1414
manager.queues[name] = new queue(name, state)
1515
}
1616

17-
manager.start = async function (name) {
17+
manager.start = function (name) {
1818
if (debugMode) console.log(`Jobs: manager.start(${name})`)
1919

2020
const action = (queue) => manager.queues[queue].start()

server/imports/operator/queue/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ queue.prototype.grabDoc = async function () {
6868
if (debugMode) console.log(`queue.prototype.grabDoc(${this.name})`)
6969

7070
const self = this;
71-
71+
7272
const jobDoc = await Utilities.collection.findOneAsync({
7373
_id: {
7474
$ne: self.previouslyRan
@@ -102,11 +102,11 @@ queue.prototype.grabDoc = async function () {
102102
return jobDoc;
103103
}
104104

105-
queue.prototype.run = function () {
105+
queue.prototype.run = async function () {
106106
if (debugMode) console.log(`queue.prototype.run(${this.name})`)
107107

108108
const self = this;
109-
const jobDoc = self.grabDoc();
109+
const jobDoc = await self.grabDoc();
110110

111111
if (jobDoc) {
112112
execute(jobDoc, function () {

server/imports/utilities/helpers/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { getJob } from "./getJob.js"
66
import { processJobArguments } from "./processJobArguments.js"
77

88
const helpers = {
9-
generateDueDate: generateDueDate,
10-
generateJobDoc: generateJobDoc,
11-
getJob: getJob,
12-
number: number,
13-
date: date,
14-
processJobArguments: processJobArguments
9+
generateDueDate,
10+
generateJobDoc,
11+
getJob,
12+
number,
13+
date,
14+
processJobArguments
1515
}
1616

1717
export { helpers }

tests/basic.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,5 @@ Tinytest.addAsync("Basic", async function (test) {
7171
console.log("--- 6 ---")
7272
var allJobDocs = await JobsInternal.Utilities.collection.find().fetchAsync();
7373
console.log(allJobDocs);
74+
test.equal(allJobDocs.length, 1)
7475
});

tests/internals.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,31 @@ Tinytest.addAsync("Internals", async function (test) {
1515

1616
console.log("--- 0 ---")
1717
var clear = await Jobs.clear("*")
18-
console.log(clear)
1918

2019
// 1 - Register the Job
2120

21+
console.log("--- 1 ---")
2222
Jobs.register({
2323
"statefulJob": async function () {
2424
self = this;
2525

26-
var count = self.get("count");
27-
console.log(self)
26+
let count = await self.get("count");
2827
console.log("I am: " + count)
29-
if (count < 5) {
3028

29+
if (count < 5) {
3130
count = count + 1;
3231
console.log("current is:" + count)
33-
self.set("count", count)
34-
35-
self.reschedule({
32+
await self.set("count", count)
33+
34+
test.equal(self.document.data.count, count)
35+
36+
await self.reschedule({
3637
in: {
3738
seconds: 5
3839
}
3940
})
4041
} else {
42+
test.equal(self.document.data.count, 5);
4143
await self.remove()
4244
}
4345

@@ -46,11 +48,13 @@ Tinytest.addAsync("Internals", async function (test) {
4648
})
4749

4850
// 2 - Schedule a job
49-
50-
var jobId = Jobs.run("statefulJob", {
51+
console.log("--- 2 ---")
52+
var jobId = await Jobs.run("statefulJob", {
5153
data: {
5254
count: 1
5355
}
5456
})
57+
console.log("Job doc after run:")
58+
console.log(jobId)
5559

5660
});

tests/replication.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ Tinytest.addAsync("Replication", async function (test) {
1818

1919
// 1 - Register the Job
2020

21-
Jobs.register({
22-
"timeThing": function () {
21+
await Jobs.register({
22+
"timeThing": async function () {
2323
doc = this.document;
2424

2525
console.log("The current time is");
@@ -30,13 +30,13 @@ Tinytest.addAsync("Replication", async function (test) {
3030

3131
console.log("");
3232

33-
this.replicate({
33+
await this.replicate({
3434
in: {
3535
seconds: 5
3636
}
3737
})
3838

39-
this.success();
39+
await this.success();
4040
}
4141
})
4242

0 commit comments

Comments
 (0)