20 return $this->classNameAlias[$class_name] ?? $class_name;
30 public function schedule($class_name,$config = null,$time = null,$interval = null){
38 public function delete($id){
50 protected function create($class_name,$id,$config = null,$time = null,$interval = null){
51 return new $class_name($this,$id,$config,$time,$interval);
58 public function instant($class_name,$config = null){
59 $this->
create($class_name,null,$config)->execute();
66 protected function next($id = null){
74 protected function lock($job){
99 $this->
delete($job->id);
118 while(($job = $this->
next($id)) && $this->
lock($job))
try{
120 $timer_id = $this->logTimerPrio ? $log->start($this->logTimerPrio,
"Executing job '{$job->id}'",__FILE__,__LINE__) : null;
122 if($timer_id) $log->stop($timer_id);
124 $diff = ($time = $job->nextTime) - time();
125 if(!$time) $log->alert(
"Invalid interval for job '{$job->id}'");
126 elseif($diff < 0) $log->warning(
"Job '{$job->id}' rescheduled in past",[
'diff' => $diff]);
129 else $this->
ready($job);
131 if((++$count >= $this->breakCount) || (time() - $start >= $this->breakTime))
break;
136 foreach($this->
overdue() as $job)
137 $log->critical(
"Job '{$job->id}' is overdue",[
'time' => $job->time,
'interval' => $job->interval]);
instant($class_name, $config=null)
Run a job instantly.
$defaultOverduePeriod
Default overdue period for jobs that do not have a rescheduling interval.
schedule($class_name, $config=null, $time=null, $interval=null)
Add a job to the queue.
$logTimerPrio
Log the begin and end times of a job with this (custom) prio.
ready($job)
Mark a job as done.
$classNameAlias
Job class name aliasses (key = alias, value = class name).
$timeLimit
Default time limit for a job (seconds).
next($id=null)
Next scheduled job to execute.
reschedule($job, $time=null)
Reschedule a job.
create($class_name, $id, $config=null, $time=null, $interval=null)
Create a job object.
transClassName($class_name)
Translate a job class name.
execute($id=null)
Execute the worker / process the scheduled jobs.
$breakCount
Halt the processig of job after this amount (even when there are more jobs scheduled).
component($name)
Get a component (local or default).
$breakTime
Halt the processig of job after this time (seconds; even when there are more jobs scheduled)...
unlock($job)
Unlock a job.