MediaWiki master
RunnableJob Interface Reference

Job that has a run() method and metadata accessors for JobQueue::pop() and JobQueue::ack(). More...

Inherits IJobSpecification.

Inherited by Job.

Collaboration diagram for RunnableJob:

Public Member Functions

 allowRetries ()
 Whether to retry execution of this job if run() returned false or threw an exception.
 
 getLastError ()
 
 getMetadata ( $field=null)
 
 getReadyTimestamp ()
 
 getRequestId ()
 
 hasExecutionFlag ( $flag)
 
 run ()
 Run the job.
 
 setMetadata ( $field, $value)
 
 tearDown ( $status)
 Do any final cleanup after run(), deferred updates, and all DB commits happen.
 
 toString ()
 
 workItemCount ()
 
- Public Member Functions inherited from IJobSpecification
 getDeduplicationInfo ()
 Subclasses may need to override this to make duplication detection work.
 
 getParams ()
 
 getReleaseTimestamp ()
 
 getRootJobParams ()
 
 getType ()
 
 hasRootJobParams ()
 
 ignoreDuplicates ()
 
 isRootJob ()
 

Detailed Description

Job that has a run() method and metadata accessors for JobQueue::pop() and JobQueue::ack().

Instances are not only enqueueable via JobQueue::push(), but they can also be executed by calling their run() method. When constructing a job to be enqueued via JobQueue::push(), it will not be possible to construct a RunnableJob instance if the class for that job is not loaded by the application for the local DB domain. In that case, the general-purpose JobSpecification class can be used instead.

See the architecture doc for more information.

Stability: stable
to implement
Since
1.33

Definition at line 36 of file RunnableJob.php.

Member Function Documentation

◆ allowRetries()

RunnableJob::allowRetries ( )

Whether to retry execution of this job if run() returned false or threw an exception.

Warning
In some setups (i.e. when using change-propagation) jobs may still be retried even when this is false if the job fails due to a timeout unless it is also configured in change-prop config (T358939).
Returns
bool Whether this job can be retried on failure by job runners
Since
1.21

Implemented in Job, AssembleUploadChunksJob, and ThumbnailRenderJob.

◆ getLastError()

RunnableJob::getLastError ( )
Returns
string

Implemented in Job.

◆ getMetadata()

RunnableJob::getMetadata ( $field = null)
Parameters
string | null$fieldMetadata field or null to get all the metadata
Returns
mixed|null Value; null if missing

Implemented in Job.

◆ getReadyTimestamp()

RunnableJob::getReadyTimestamp ( )
Returns
int|null UNIX timestamp of when the job was runnable, or null
Since
1.26

Implemented in Job.

◆ getRequestId()

RunnableJob::getRequestId ( )
Returns
string|null Id of the request that created this job. Follows jobs recursively, allowing to track the id of the request that started a job when jobs insert jobs which insert other jobs.
Since
1.27

Implemented in Job.

◆ hasExecutionFlag()

RunnableJob::hasExecutionFlag ( $flag)
Parameters
int$flagJOB_* class constant
Returns
bool
Since
1.31

Implemented in Job.

◆ run()

RunnableJob::run ( )

Run the job.

If this method returns false or completes exceptionally, the job runner will retry executing this job unless the number of retries has exceeded its configured retry limit. Retries are allowed by default, unless allowRetries() is overridden to disable retries.

See the architecture doc for more information.

Returns
bool Return false to instruct the job runner to retry a failed job. Otherwise return true to indicate that a job completed (i.e. succeeded, or failed in a way that's deterministic or redundant).

Implemented in AssembleUploadChunksJob, CategoryMembershipChangeJob, CdnPurgeJob, DeleteLinksJob, DeletePageJob, DoubleRedirectJob, DuplicateJob, HTMLCacheUpdateJob, NullJob, ParsoidCachePrewarmJob, RefreshLinksJob, RevertedTagUpdateJob, ThumbnailRenderJob, UserOptionsUpdateJob, EmaillingJob, EnotifNotifyJob, RecentChangesUpdateJob, MediaWiki\RenameUser\RenameUserJob, UserEditCountInitJob, UserGroupExpiryJob, MediaWiki\Watchlist\ActivityUpdateJob, MediaWiki\Watchlist\ClearUserWatchlistJob, MediaWiki\Watchlist\ClearWatchlistNotificationsJob, and MediaWiki\Watchlist\WatchlistExpiryJob.

◆ setMetadata()

RunnableJob::setMetadata ( $field,
$value )
Parameters
string$fieldKey name to set the value for
mixed$valueThe value to set the field for
Returns
mixed|null The prior field value; null if missing

Implemented in Job.

◆ tearDown()

RunnableJob::tearDown ( $status)

Do any final cleanup after run(), deferred updates, and all DB commits happen.

Parameters
bool$statusWhether the job, its deferred updates, and DB commit all succeeded
Since
1.27

◆ toString()

RunnableJob::toString ( )
Returns
string Debugging string describing the job

Implemented in Job.

◆ workItemCount()

RunnableJob::workItemCount ( )
Returns
int Number of actually "work items" handled in this job
See also
$wgJobBackoffThrottling
Since
1.23

Implemented in Job, HTMLCacheUpdateJob, and RefreshLinksJob.


The documentation for this interface was generated from the following file: