forked from GladysAssistant/Gladys
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add core scheduler for all entities / integrations (GladysAssistant#1641
- Loading branch information
Showing
45 changed files
with
2,453 additions
and
1,650 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
const jobs = require('../../config/scheduler-jobs'); | ||
const schedule = require('node-schedule'); | ||
|
||
const { cancel } = require('./scheduler.cancel'); | ||
const { scheduleJob } = require('./scheduler.scheduleJob'); | ||
const { cancelJob } = require('./scheduler.cancelJob'); | ||
const { init } = require('./scheduler.init'); | ||
const { run } = require('./scheduler.run'); | ||
|
||
const Scheduler = function Scheduler(event) { | ||
this.event = event; | ||
this.jobs = jobs; | ||
this.jobsScheduled = {}; | ||
this.nodeSchedule = schedule; | ||
}; | ||
|
||
Scheduler.prototype.cancel = cancel; | ||
Scheduler.prototype.scheduleJob = scheduleJob; | ||
Scheduler.prototype.cancelJob = cancelJob; | ||
Scheduler.prototype.init = init; | ||
Scheduler.prototype.run = run; | ||
|
||
module.exports = Scheduler; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* @description Cancel job | ||
* @param {string} jobName - Job name to cancel. | ||
* @example | ||
* scheduler.cancelJob('my-job'); | ||
*/ | ||
function cancelJob(jobName) { | ||
this.nodeSchedule.cancelJob(jobName); | ||
} | ||
|
||
module.exports = { | ||
cancelJob, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* @description Schedule new job. | ||
* @param {Object|string|Date} rule - Rule to execute the job. | ||
* @param {Function} method - The method to execute. | ||
* @returns {Object} The scheduled job. | ||
* @example | ||
* scheduler.scheduleJob({ hour: 12 }, () => console.log('job is running')); | ||
*/ | ||
function scheduleJob(rule, method) { | ||
return this.nodeSchedule.scheduleJob(rule, method); | ||
} | ||
|
||
module.exports = { | ||
scheduleJob, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.