Merge "Add support for PHP7 random_bytes in favor of mcrypt_create_iv"
[lhc/web/wiklou.git] / includes / libs / rdbms / lbfactory / LBFactorySimple.php
index 674bafd..15cd508 100644 (file)
  * @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(),