Skip to content

Commit

Permalink
v2.0.2
Browse files Browse the repository at this point in the history
 - πŸ‘·β€β™‚οΈ Codebase maintenance, minor enhancements
 - 🀝 Compatibility with `mongodb@3.1.*` (*native-driver*)
 - πŸ‘¨β€πŸ’» Regular release
  • Loading branch information
dr-dimitru committed Sep 25, 2018
1 parent 22cd836 commit b719a18
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 116 deletions.
20 changes: 14 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const NoOp = () => {};
const _debug = (message) => {
console.trace();
console.warn(message);
console.warn('[josk]', message);
};
const prefixRegex = /(setImmediate|setTimeout|setInterval)$/;

Expand Down Expand Up @@ -34,8 +34,16 @@ module.exports = class JoSk {
}

this.collection = opts.db.collection(`__JobTasks__${this.prefix}`);
this.collection.ensureIndex({uid: 1}, {background: true, unique: true});
this.collection.ensureIndex({executeAt: 1, inProgress: 1}, {background: true});
this.collection.createIndex({uid: 1}, {background: true, unique: true}, (indexError) => {
if (indexError) {
_debug(indexError);
}
});
this.collection.createIndex({executeAt: 1, inProgress: 1}, {background: true}, (indexError) => {
if (indexError) {
_debug(indexError);
}
});

if (this.resetOnInit) {
this.collection.updateMany({}, {
Expand Down Expand Up @@ -205,7 +213,7 @@ module.exports = class JoSk {
this.collection.insertOne({
uid: uid,
delay: delay,
executeAt: new Date(+new Date() + delay),
executeAt: new Date(Date.now() + delay),
isInterval: isInterval,
inProgress: false
}, NoOp);
Expand All @@ -218,11 +226,11 @@ module.exports = class JoSk {
update.delay = delay;
}

if (+task.executeAt > +new Date() + delay) {
if (+task.executeAt > Date.now() + delay) {
if (!update) {
update = {};
}
update.executeAt = new Date(+new Date() + delay);
update.executeAt = new Date(Date.now() + delay);
}

if (update) {
Expand Down
131 changes: 39 additions & 92 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 27 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
{
"name": "josk",
"version": "2.0.1",
"version": "2.0.2",
"description": "Task and jobs runner. With support of multiple clusters and servers setup",
"main": "index.js",
"scripts": {
"test": "mocha"
},
"repository": {
"type": "git",
"url": "git://github.com/VeliovGroup/josk.git"
},
"keywords": [
"tasks",
"jobs",
Expand All @@ -22,15 +18,37 @@
"job",
"schedule"
],
"tags": [
"tasks",
"jobs",
"cluster",
"scheduler",
"agent",
"agenda",
"servers",
"task",
"job",
"schedule"
],
"repository": {
"type": "git",
"url": "git://github.com/VeliovGroup/josk.git"
},
"bugs": {
"url": "https://github.com/VeliovGroup/josk/issues"
},
"homepage": "https://github.com/VeliovGroup/josk",
"author": "dr.dimitru (https://veliovgroup.com)",
"license": "BSD-3-Clause",
"engines": {
"node": ">=8.9.0"
},
"devDependencies": {
"mongodb": "^3.0.1",
"mocha": "^5.0.0",
"chai": "^4.1.2",
"josk": "file://./"
}
"josk": "file://./",
"mocha": "^5.2.0",
"mongodb": "^3.1.6",
"pathval": "^1.1.0"
},
"dependencies": {}
}
Loading

0 comments on commit b719a18

Please sign in to comment.