MediaWiki REL1_39
JobQueueGroupFactory.php
Go to the documentation of this file.
1<?php
22
29use WikiMap;
31
42 public const CONSTRUCTOR_OPTIONS = [
47 ];
48
50 private $instances;
51
53 private $options;
54
56 private $readOnlyMode;
57
59 private $statsdDataFactory;
60
62 private $wanCache;
63
65 private $globalIdGenerator;
66
74 public function __construct(
75 ServiceOptions $options,
76 ConfiguredReadOnlyMode $readOnlyMode,
77 IBufferingStatsdDataFactory $statsdDataFactory,
78 WANObjectCache $wanCache,
79 GlobalIdGenerator $globalIdGenerator
80 ) {
81 $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
82 $this->instances = [];
83 $this->options = $options;
84 $this->readOnlyMode = $readOnlyMode;
85 $this->statsdDataFactory = $statsdDataFactory;
86 $this->wanCache = $wanCache;
87 $this->globalIdGenerator = $globalIdGenerator;
88 }
89
96 public function makeJobQueueGroup( $domain = false ): JobQueueGroup {
97 if ( $domain === false ) {
98 $domain = WikiMap::getCurrentWikiDbDomain()->getId();
99 }
100
101 if ( !isset( $this->instances[$domain] ) ) {
102 // Make sure jobs are not getting pushed to bogus wikis. This can confuse
103 // the job runner system into spawning endless RPC requests that fail (T171371).
104 $wikiId = WikiMap::getWikiIdFromDbDomain( $domain );
105 if (
106 !WikiMap::isCurrentWikiDbDomain( $domain ) &&
107 !in_array( $wikiId, $this->options->get( MainConfigNames::LocalDatabases ) )
108 ) {
109 $invalidDomain = true;
110 } else {
111 $invalidDomain = false;
112 }
113
114 $this->instances[$domain] = new JobQueueGroup(
115 $domain,
116 $this->readOnlyMode,
117 $invalidDomain,
118 $this->options->get( MainConfigNames::JobClasses ),
119 $this->options->get( MainConfigNames::JobTypeConf ),
121 $this->statsdDataFactory,
122 $this->wanCache,
123 $this->globalIdGenerator
124 );
125 }
126
127 return $this->instances[$domain];
128 }
129}
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Definition WebStart.php:82
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)
A class containing constants representing the names of configuration variables.
const JobTypeConf
Name constant for the JobTypeConf setting, for use with Config::get()
const LocalDatabases
Name constant for the LocalDatabases setting, for use with Config::get()
const JobClasses
Name constant for the JobClasses setting, for use with Config::get()
const JobTypesExcludedFromDefaultQueue
Name constant for the JobTypesExcludedFromDefaultQueue setting, for use with Config::get()
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.