3 * Job queue task instance that can be executed via a run() method
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 * Job that has a run() method and metadata accessors for JobQueue::pop() and JobQueue::ack()
26 * Instances are not only enqueueable via JobQueue::push(), but they can also be executed by
27 * by calling their run() method. When constructing a job to be enqueued via JobQueue::push(),
28 * it will not be possible to construct a RunnableJob instance if the class for that job is not
29 * loaded by the application for the local DB domain. In that case, the general-purpose
30 * JobSpecification class can be used instead.
35 interface RunnableJob
extends IJobSpecification
{
36 /** @var int Job must not be wrapped in the usual explicit LBFactory transaction round */
37 const JOB_NO_EXPLICIT_TRX_ROUND
= 1;
41 * @return bool Success
43 public function run();
46 * @param string|null $field Metadata field or null to get all the metadata
47 * @return mixed|null Value; null if missing
49 public function getMetadata( $field = null );
52 * @param string $field Key name to set the value for
53 * @param mixed $value The value to set the field for
54 * @return mixed|null The prior field value; null if missing
56 public function setMetadata( $field, $value );
59 * @param int $flag JOB_* class constant
63 public function hasExecutionFlag( $flag );
66 * @return string|null Id of the request that created this job. Follows
67 * jobs recursively, allowing to track the id of the request that started a
68 * job when jobs insert jobs which insert other jobs.
71 public function getRequestId();
74 * @return bool Whether this job can be retried on failure by job runners
77 public function allowRetries();
80 * @return int Number of actually "work items" handled in this job
81 * @see $wgJobBackoffThrottling
84 public function workItemCount();
87 * @return int|null UNIX timestamp of when the job was runnable, or null
90 public function getReadyTimestamp();
93 * Do any final cleanup after run(), deferred updates, and all DB commits happen
94 * @param bool $status Whether the job, its deferred updates, and DB commit all succeeded
97 public function tearDown( $status );
102 public function getLastError();
105 * @return string Debugging string describing the job
107 public function toString();