1.2.8. Scheduler service-1.0¶
This service schedule some jobs and commands, using cron expressions.
1.2.8.1. Using Cron expression¶
Cron expression permit a large variety of time period and date. Some additional web site permit to define the cron expression with some help. https://www.freeformatter.com/cron-expression-generator-quartz.html
croner library is used in the scheduling cron definition : https://docs.rs/croner/latest/croner/ , more informations about the cron expressions on this page : https://github.com/hexagon/croner-rust
1.2.8.2. Scheduler implementation¶
Jobs are stored in a small database, there are two kind of informations (tables):
jobs : contains the jobs and associated timing rules
job_executions : the log of executed jobs
jobs definition example:
[
{
"name":"display",
"cron":"* * * * *",
"activated":true,
"executed_expression":"hello('me')"
},
{
"name":"supervisor",
"cron":"*/20 * * * *",
"activated":true,
"executed_expression":"hello('world')"
}
]
executed job logs may need to be cleaned when no more relevant.
1.2.8.3. Scheduler behaviour¶
Scheduled jobs have a “last executed time” committed, once defined and executed (for periodic jobs), then the next scheduled time is computed and compared to the current time. if the time is more recent that the latest objective, the job will be triggered, and the current executed time will be stored.