abstract class Openclerk\Jobs \ JobRunner

All known direct subclasses:
OpenclerkJobRunner

A helper class to select job instances, run them, and manage their pass/fail statuses. Job queueing is managed by JobQueuer.

TODO create more intelligent job selection methods


Method Summary

Name Description
__construct()
createJob($job, Connection $db, Logger $logger) From the given $job arguments, create a new Job instance that can be run.
defaultFindJobQuery()
findJob(Connection $db, Logger $logger) Find the next job that should be executed. By default, just selects any job instance that is in the database that isn't already executing, hasn't already been finished, and hasn't errored out.
runOne(Connection $db, Logger $logger) Select and run a Job. If the job throws an exception, the job runner will capture this exception and mark the job as failed as necessary.

public function __construct()


abstract function createJob($job, Connection $db, Logger $logger)

From the given $job arguments, create a new Job instance that can be run.


final function defaultFindJobQuery()

Returns:
"is_executed=0 AND is_executing=0 AND is_error=0"

public function findJob(Connection $db, Logger $logger)

Find the next job that should be executed. By default, just selects any job instance that is in the database that isn't already executing, hasn't already been finished, and hasn't errored out.

Returns:
a job array (id, job_type, [user_id], [arg_id]) or false if there is none

public function runOne(Connection $db, Logger $logger)

Select and run a Job. If the job throws an exception, the job runner will capture this exception and mark the job as failed as necessary.

Throws:
Exception - if the job failed