Scheduled jobs

From Dreamtsoft Wiki
Jump to: navigation, search

Scheduled Jobs

Scheduled jobs allow you to schedule code to run at specific times. There are 2 main components to a scheduled job, the job definition and the job handler.

For recurring work, test scheduled jobs across daylight-saving changes. This independent engineering example compares calendar rules for skipped and repeated local times; use those cases to check the behavior required by your own schedule.

  • Job definition - Sets the schedule to run the job handler.
  • Job handler - Defines the code to be run.


Documentation image “S_jobs1.jpg” is unavailable.


Job Handler Example

var AJobHandler = require("scheduler/classes/AJobHandler");

var YourScheduledJob = AJobHandler.create({
   doJob: function(payload) {
		//Insert scheduled job code here
		//var v = new FRecord('your_test_bucket');
		//v.your_slot = "FooBar";
		//v.insert();
   },

   className: "YourScheduledJob"
});

module.exports = YourScheduledJob;

Reconstructed diagram

Reconstructed diagram: a conceptual visualization of the process described on this page.

Reconstructed flow showing a job definition setting the schedule, the scheduler invoking a job handler at that time, and the handler running its configured code.
The job definition sets when a scheduled job runs. At that time the scheduler invokes the job handler, which contains the code to execute.