60 $this->
type = $params[
'type'];
61 $this->claimTTL = isset(
$params[
'claimTTL'] ) ?
$params[
'claimTTL'] : 0;
62 $this->maxTries = isset(
$params[
'maxTries'] ) ?
$params[
'maxTries'] : 3;
64 $this->
order = $params[
'order'];
69 throw new MWException( __CLASS__ .
" does not support '{$this->order}' order." );
72 $this->aggr = isset(
$params[
'aggregator'] )
75 $this->readOnlyReason = isset(
$params[
'readOnlyReason'] )
110 if ( !class_exists( $class ) ) {
111 throw new MWException(
"Invalid job queue class '$class'." );
114 if ( !( $obj instanceof
self ) ) {
115 throw new MWException(
"Class '$class' is not a " . __CLASS__ .
" class." );
304 final public function push( $jobs, $flags = 0 ) {
305 $jobs = is_array( $jobs ) ? $jobs : [ $jobs ];
319 final public function batchPush( array $jobs, $flags = 0 ) {
322 if ( !count( $jobs ) ) {
326 foreach ( $jobs as
$job ) {
327 if (
$job->getType() !== $this->type ) {
329 "Got '{$job->getType()}' job; expected a '{$this->type}' job." );
330 } elseif (
$job->getReleaseTimestamp() && !$this->supportsDelayedJobs() ) {
332 "Got delayed '{$job->getType()}' job; delays are not supported." );
337 $this->aggr->notifyQueueNonEmpty( $this->wiki, $this->
type );
339 foreach ( $jobs as
$job ) {
340 if (
$job->isRootJob() ) {
361 final public function pop() {
366 throw new MWException(
"Cannot pop '{$this->type}' job off foreign wiki queue." );
369 throw new MWException(
"Unrecognized job type '{$this->type}'." );
375 $this->aggr->notifyQueueEmpty( $this->wiki, $this->type );
384 }
catch ( Exception
$e ) {
395 abstract protected function doPop();
409 if ( $job->
getType() !== $this->type ) {
410 throw new MWException(
"Got '{$job->getType()}' job; expected '{$this->type}'." );
413 $this->
doAck( $job );
455 if ( $job->
getType() !== $this->type ) {
456 throw new MWException(
"Got '{$job->getType()}' job; expected '{$this->type}'." );
469 if ( !
$job->hasRootJobParams() ) {
470 throw new MWException(
"Cannot register root job; missing parameters." );
480 $timestamp = $this->dupCache->get( $key );
481 if ( $timestamp && $timestamp >=
$params[
'rootJobTimestamp'] ) {
497 if (
$job->getType() !== $this->type ) {
498 throw new MWException(
"Got '{$job->getType()}' job; expected '{$this->type}'." );
511 if ( !
$job->hasRootJobParams() ) {
518 $timestamp = $this->dupCache->get( $key );
521 return ( $timestamp && $timestamp >
$params[
'rootJobTimestamp'] );
541 final public function delete() {
552 throw new MWException(
"This method is not implemented." );
609 return new ArrayIterator( [] );
623 return new ArrayIterator( [] );
634 return new ArrayIterator( [] );
696 if ( $this->readOnlyReason !==
false ) {
712 $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
714 $stats->updateCount(
"jobqueue.{$key}.all", $delta );
715 $stats->updateCount(
"jobqueue.{$key}.{$type}", $delta );
wfSplitWikiID( $wiki)
Split a wiki ID into DB name and table prefix.
wfForeignMemcKey( $db, $prefix)
Make a cache key for a foreign DB.
wfGetCache( $cacheType)
Get a specific cache object.
$wgJobClasses['replaceText']
interface is intended to be more or less compatible with the PHP memcached client.
static newFromJob(Job $job)
Get a duplicate no-op version of a job.
Class to handle tracking information about all queues.
Class to handle enqueueing and running of background jobs.
isEmpty()
Quickly check if the queue has no available (unacquired, non-delayed) jobs.
string $order
Job priority for pop()
__construct(array $params)
getAbandonedCount()
Get the number of acquired jobs that can no longer be attempted.
waitForBackups()
Wait for any replica DBs or backup servers to catch up.
isRootJobOldDuplicate(Job $job)
Check if the "root" job of a given job has been superseded by a newer one.
static incrStats( $key, $type, $delta=1)
Call wfIncrStats() for the queue overall and for the queue type.
push( $jobs, $flags=0)
Push one or more jobs into the queue.
pop()
Pop a job off of the queue.
int $claimTTL
Time to live in seconds.
doDeduplicateRootJob(IJobSpecification $job)
getCoalesceLocationInternal()
Do not use this function outside of JobQueue/JobQueueGroup.
batchPush(array $jobs, $flags=0)
Push a batch of jobs into the queue.
doGetSiblingQueueSizes(array $types)
supportsDelayedJobs()
Find out if delayed jobs are supported for configuration validation.
getSiblingQueueSizes(array $types)
Check the size of each of the given queues.
int $maxTries
Maximum number of times to try a job.
getAllQueuedJobs()
Get an iterator to traverse over all available jobs in this queue.
static factory(array $params)
Get a job queue object of the specified type.
getAllAbandonedJobs()
Get an iterator to traverse over all abandoned jobs in this queue.
doBatchPush(array $jobs, $flags)
ack(Job $job)
Acknowledge that a job was completed.
getAllAcquiredJobs()
Get an iterator to traverse over all claimed jobs in this queue.
string bool $readOnlyReason
Read only rationale (or false if r/w)
doGetSiblingQueuesWithJobs(array $types)
deduplicateRootJob(IJobSpecification $job)
Register the "root job" of a given job into the queue for de-duplication.
getSize()
Get the number of available (unacquired, non-delayed) jobs in the queue.
getAcquiredCount()
Get the number of acquired jobs (these are temporarily out of the queue).
doIsRootJobOldDuplicate(Job $job)
flushCaches()
Clear any process and persistent caches.
getAllDelayedJobs()
Get an iterator to traverse over all delayed jobs in this queue.
supportedOrders()
Get the allowed queue orders for configuration validation.
getSiblingQueuesWithJobs(array $types)
Check whether each of the given queues are empty.
getRootJobCacheKey( $signature)
optimalOrder()
Get the default queue order to use if configuration does not specify one.
getDelayedCount()
Get the number of delayed jobs (these are temporarily out of the queue).
Class to both describe a background job and handle jobs.
static isCurrentWikiDbDomain( $domain)
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any order
returning false will NOT prevent logging $e
Job queue task description interface.
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
if(count( $args)< 1) $job