X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2Frdbms%2Flbfactory%2FLBFactorySimple.php;h=1e69d8fd3c14ec3778b843d4d582601a4fe6aef8;hb=49748181dd56ec97e7ba7c13e684a16abceb3cc0;hp=674bafd99114393d75485b5f11b14401da727360;hpb=a6c5f1a81599bc24005554f330f56d7a1b054d4b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/rdbms/lbfactory/LBFactorySimple.php b/includes/libs/rdbms/lbfactory/LBFactorySimple.php index 674bafd991..15cd50849d 100644 --- a/includes/libs/rdbms/lbfactory/LBFactorySimple.php +++ b/includes/libs/rdbms/lbfactory/LBFactorySimple.php @@ -21,6 +21,10 @@ * @ingroup Database */ +namespace Wikimedia\Rdbms; + +use InvalidArgumentException; + /** * A simple single-master LBFactory that gets its configuration from the b/c globals */ @@ -91,13 +95,7 @@ class LBFactorySimple extends LBFactory { return $this->mainLB; } - /** - * @param string $cluster - * @param bool|string $domain - * @return LoadBalancer - * @throws InvalidArgumentException - */ - public function newExternalLB( $cluster, $domain = false ) { + public function newExternalLB( $cluster ) { if ( !isset( $this->externalClusters[$cluster] ) ) { throw new InvalidArgumentException( __METHOD__ . ": Unknown cluster \"$cluster\"." ); } @@ -105,20 +103,28 @@ class LBFactorySimple extends LBFactory { return $this->newLoadBalancer( $this->externalClusters[$cluster] ); } - /** - * @param string $cluster - * @param bool|string $domain - * @return LoadBalancer - */ - public function getExternalLB( $cluster, $domain = false ) { + public function getExternalLB( $cluster ) { if ( !isset( $this->extLBs[$cluster] ) ) { - $this->extLBs[$cluster] = $this->newExternalLB( $cluster, $domain ); + $this->extLBs[$cluster] = $this->newExternalLB( $cluster ); $this->getChronologyProtector()->initLB( $this->extLBs[$cluster] ); } return $this->extLBs[$cluster]; } + public function getAllMainLBs() { + return [ 'DEFAULT' => $this->getMainLB() ]; + } + + public function getAllExternalLBs() { + $lbs = []; + foreach ( $this->externalClusters as $cluster => $unused ) { + $lbs[$cluster] = $this->getExternalLB( $cluster ); + } + + return $lbs; + } + private function newLoadBalancer( array $servers ) { $lb = new LoadBalancer( array_merge( $this->baseLoadBalancerParams(),