MediaWiki REL1_31
JobQueueAggregator.php
Go to the documentation of this file.
1<?php
29abstract class JobQueueAggregator {
31 protected static $instance = null;
32
36 public function __construct( array $params ) {
37 }
38
43 final public static function singleton() {
45
46 if ( !isset( self::$instance ) ) {
47 $class = $wgJobQueueAggregator['class'];
48 $obj = new $class( $wgJobQueueAggregator );
49 if ( !( $obj instanceof JobQueueAggregator ) ) {
50 throw new MWException( "Class '$class' is not a JobQueueAggregator class." );
51 }
52 self::$instance = $obj;
53 }
54
55 return self::$instance;
56 }
57
63 final public static function destroySingleton() {
64 self::$instance = null;
65 }
66
74 final public function notifyQueueEmpty( $wiki, $type ) {
75 $ok = $this->doNotifyQueueEmpty( $wiki, $type );
76
77 return $ok;
78 }
79
86 abstract protected function doNotifyQueueEmpty( $wiki, $type );
87
95 final public function notifyQueueNonEmpty( $wiki, $type ) {
96 $ok = $this->doNotifyQueueNonEmpty( $wiki, $type );
97
98 return $ok;
99 }
100
107 abstract protected function doNotifyQueueNonEmpty( $wiki, $type );
108
114 final public function getAllReadyWikiQueues() {
115 $res = $this->doGetAllReadyWikiQueues();
116
117 return $res;
118 }
119
123 abstract protected function doGetAllReadyWikiQueues();
124
130 final public function purge() {
131 $res = $this->doPurge();
132
133 return $res;
134 }
135
139 abstract protected function doPurge();
140
147 protected function findPendingWikiQueues() {
149
150 $pendingDBs = []; // (job type => (db list))
151 foreach ( $wgLocalDatabases as $db ) {
152 foreach ( JobQueueGroup::singleton( $db )->getQueuesWithJobs() as $type ) {
153 $pendingDBs[$type][] = $db;
154 }
155 }
156
157 return $pendingDBs;
158 }
159}
160
165 protected function doNotifyQueueEmpty( $wiki, $type ) {
166 return true;
167 }
168
169 protected function doNotifyQueueNonEmpty( $wiki, $type ) {
170 return true;
171 }
172
173 protected function doGetAllReadyWikiQueues() {
174 return [];
175 }
176
177 protected function doPurge() {
178 return true;
179 }
180}
$wgLocalDatabases
Other wikis on this site, can be administered from a single developer account.
$wgJobQueueAggregator
Which aggregator to use for tracking which queues have jobs.
doNotifyQueueNonEmpty( $wiki, $type)
Class to handle tracking information about all queues.
__construct(array $params)
getAllReadyWikiQueues()
Get the list of all of the queues with jobs.
findPendingWikiQueues()
Get all databases that have a pending job.
notifyQueueNonEmpty( $wiki, $type)
Mark a queue as being non-empty.
static destroySingleton()
Destroy the singleton instance.
doNotifyQueueEmpty( $wiki, $type)
doNotifyQueueNonEmpty( $wiki, $type)
static JobQueueAggregator $instance
purge()
Purge all of the aggregator information.
notifyQueueEmpty( $wiki, $type)
Mark a queue as being empty.
static singleton( $domain=false)
MediaWiki exception.
$res
Definition database.txt:21
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
the array() calling protocol came about after MediaWiki 1.4rc1.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
$params