MediaWiki REL1_37
JobQueueGroupFactory.php
Go to the documentation of this file.
1<?php
22
28use WikiMap;
30
41 public const CONSTRUCTOR_OPTIONS = [
42 'JobClasses',
43 'JobTypeConf',
44 'JobTypesExcludedFromDefaultQueue',
45 'LocalDatabases',
46 ];
47
49 private $instances;
50
52 private $options;
53
56
59
61 private $wanCache;
62
65
73 public function __construct(
79 ) {
80 $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
81 $this->instances = [];
82 $this->options = $options;
83 $this->readOnlyMode = $readOnlyMode;
84 $this->statsdDataFactory = $statsdDataFactory;
85 $this->wanCache = $wanCache;
86 $this->globalIdGenerator = $globalIdGenerator;
87 }
88
95 public function makeJobQueueGroup( $domain = false ): JobQueueGroup {
96 if ( $domain === false ) {
97 $domain = WikiMap::getCurrentWikiDbDomain()->getId();
98 }
99
100 if ( !isset( $this->instances[$domain] ) ) {
101 // Make sure jobs are not getting pushed to bogus wikis. This can confuse
102 // the job runner system into spawning endless RPC requests that fail (T171371).
103 $wikiId = WikiMap::getWikiIdFromDbDomain( $domain );
104 if (
105 !WikiMap::isCurrentWikiDbDomain( $domain ) &&
106 !in_array( $wikiId, $this->options->get( 'LocalDatabases' ) )
107 ) {
108 $invalidDomain = true;
109 } else {
110 $invalidDomain = false;
111 }
112
113 $this->instances[$domain] = new JobQueueGroup(
114 $domain,
115 $this->readOnlyMode,
116 $invalidDomain,
117 $this->options->get( 'JobClasses' ),
118 $this->options->get( 'JobTypeConf' ),
119 $this->options->get( 'JobTypesExcludedFromDefaultQueue' ),
120 $this->statsdDataFactory,
121 $this->wanCache,
122 $this->globalIdGenerator
123 );
124 }
125
126 return $this->instances[$domain];
127 }
128}
if(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.
Definition Setup.php:88
A read-only mode service which does not depend on LoadBalancer.
Class to handle enqueueing of background jobs.
A class for passing options to services.
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
Class to construct JobQueueGroups.
__construct(ServiceOptions $options, ConfiguredReadOnlyMode $readOnlyMode, IBufferingStatsdDataFactory $statsdDataFactory, WANObjectCache $wanCache, GlobalIdGenerator $globalIdGenerator)
IBufferingStatsdDataFactory $statsdDataFactory
Multi-datacenter aware caching interface.
Helper tools for dealing with other locally-hosted wikis.
Definition WikiMap.php:29
Class for getting statistically unique IDs without a central coordinator.
MediaWiki adaptation of StatsdDataFactory that provides buffering functionality.