Use HttpRequestFactory::createMultiClient() in core where possible
* Use createMultiClient() in CdnCacheUpdate. This will reduce the timeout from a hard-coded 900s to a configurable 25s. This is not used in WMF production. * Use createMultiClient() in the VirtualRESTServiceClient service. This should have no effect in production since the service is broken per T175224. * Use the new createMultiClient() in the old createMultiClient(). The configuration is the same except that the maximum timeouts are now respected. Bug: T245170 Change-Id: I63139d29471bc59e9ef60032fd812a1f24644113
This commit is contained in:
parent
1fd6b9aee4
commit
feba7ee306
3 changed files with 8 additions and 14 deletions
|
|
@ -1231,7 +1231,8 @@ return [
|
|||
function ( MediaWikiServices $services ) : VirtualRESTServiceClient {
|
||||
$config = $services->getMainConfig()->get( 'VirtualRestConfig' );
|
||||
|
||||
$vrsClient = new VirtualRESTServiceClient( new MultiHttpClient( [] ) );
|
||||
$vrsClient = new VirtualRESTServiceClient(
|
||||
$services->getHttpRequestFactory()->createMultiClient() );
|
||||
foreach ( $config['paths'] as $prefix => $serviceConfig ) {
|
||||
$class = $serviceConfig['class'];
|
||||
// Merge in the global defaults
|
||||
|
|
|
|||
|
|
@ -315,7 +315,8 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
|
|||
}
|
||||
}
|
||||
|
||||
$http = new MultiHttpClient( [ 'maxConnsPerHost' => 8, 'usePipelining' => true ] );
|
||||
$http = MediaWikiServices::getInstance()->getHttpRequestFactory()
|
||||
->createMultiClient( [ 'maxConnsPerHost' => 8, 'usePipelining' => true ] );
|
||||
$http->runMulti( $reqs );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
* @file
|
||||
*/
|
||||
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
|
|
@ -135,21 +134,14 @@ class Http {
|
|||
/**
|
||||
* Get a configured MultiHttpClient
|
||||
*
|
||||
* @deprecated since 1.34, construct it directly
|
||||
* @deprecated since 1.34, use MediaWikiServices::getHttpRequestFactory()->createMultiClient()
|
||||
* @param array $options
|
||||
* @return MultiHttpClient
|
||||
*/
|
||||
public static function createMultiClient( array $options = [] ) {
|
||||
wfDeprecated( __METHOD__, '1.34' );
|
||||
|
||||
global $wgHTTPConnectTimeout, $wgHTTPTimeout, $wgHTTPProxy;
|
||||
|
||||
return new MultiHttpClient( $options + [
|
||||
'connTimeout' => $wgHTTPConnectTimeout,
|
||||
'reqTimeout' => $wgHTTPTimeout,
|
||||
'userAgent' => self::userAgent(),
|
||||
'proxy' => $wgHTTPProxy,
|
||||
'logger' => LoggerFactory::getInstance( 'http' )
|
||||
] );
|
||||
global $wgHTTPProxy;
|
||||
return MediaWikiServices::getInstance()->getHttpRequestFactory()
|
||||
->createMultiClient( $options + [ 'proxy' => $wgHTTPProxy ] );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue