Doc: [cronjob manager] Doc for implementing cronjob

This commit is contained in:
2022-12-12 22:48:57 +01:00
parent 17461aa21e
commit 0bfb5c617e
5 changed files with 141 additions and 7 deletions

View File

@@ -19,6 +19,25 @@ use Exception;
use Psr\Log\LoggerInterface;
use function array_key_exists;
/**
* Manage cronjob and execute them.
*
* If any :code:`job` argument is given, the :code:`CronManager` schedule job with those steps:
*
* - the tasks are ordered, with:
* - a priority is given for tasks that weren't never executed;
* - then, the tasks are ordered, the last executed are the first in the list
*
* Then, for each tasks, and in the given order, the first task where :code:`canRun` return :code:`TRUE` will be executed.
*
* The error inside job execution are catched (with the exception of _out of memory error_).
*
* The manager will mark the task as executed even if an error is catched. This will lead as failed job
* will not have priority any more on other tasks.
*
* If a tasks is "forced", there is no test about eligibility of the task (the `canRun` method is not called),
* and the last task execution is not recorded.
*/
class CronManager implements CronManagerInterface
{
private const LOG_PREFIX = '[cron manager] ';