26use InvalidArgumentException;
58 parent::__construct( $conf );
60 $this->
servers = isset( $conf[
'servers'] ) ? $conf[
'servers'] : [];
61 foreach ( $this->
servers as $i => $server ) {
63 $this->
servers[$i][
'master'] =
true;
65 $this->
servers[$i][
'replica'] =
true;
69 $this->externalClusters = isset( $conf[
'externalClusters'] )
70 ? $conf[
'externalClusters']
72 $this->loadMonitorClass = isset( $conf[
'loadMonitorClass'] )
73 ? $conf[
'loadMonitorClass']
90 if ( !isset( $this->mainLB ) ) {
91 $this->mainLB = $this->
newMainLB( $domain );
98 if ( !isset( $this->externalClusters[$cluster] ) ) {
99 throw new InvalidArgumentException( __METHOD__ .
": Unknown cluster \"$cluster\"." );
106 if ( !isset( $this->extLBs[$cluster] ) ) {
110 return $this->extLBs[$cluster];
114 return [
'DEFAULT' => $this->
getMainLB() ];
119 foreach ( $this->externalClusters as $cluster => $unused ) {
130 'servers' => $servers,
131 'loadMonitor' => [
'class' => $this->loadMonitorClass ],
148 if ( isset( $this->mainLB ) ) {
149 call_user_func_array( $callback, array_merge( [ $this->mainLB ],
$params ) );
151 foreach ( $this->extLBs as $lb ) {
152 call_user_func_array( $callback, array_merge( [ $lb ],
$params ) );
storage can be distributed across multiple servers