namespace Wikimedia\Rdbms;
-use LoadBalancer;
use InvalidArgumentException;
/**
/** @var string */
private $loadMonitorClass;
+ /** @var int */
+ private $maxLag;
+
+ /** @var int Default 'maxLag' when unspecified */
+ const MAX_LAG_DEFAULT = 10;
/**
* @see LBFactory::__construct()
$this->loadMonitorClass = isset( $conf['loadMonitorClass'] )
? $conf['loadMonitorClass']
: 'LoadMonitor';
+ $this->maxLag = isset( $conf['maxLag'] ) ? $conf['maxLag'] : self::MAX_LAG_DEFAULT;
}
/**
public function getMainLB( $domain = false ) {
if ( !isset( $this->mainLB ) ) {
$this->mainLB = $this->newMainLB( $domain );
- $this->getChronologyProtector()->initLB( $this->mainLB );
}
return $this->mainLB;
public function getExternalLB( $cluster ) {
if ( !isset( $this->extLBs[$cluster] ) ) {
$this->extLBs[$cluster] = $this->newExternalLB( $cluster );
- $this->getChronologyProtector()->initLB( $this->extLBs[$cluster] );
}
return $this->extLBs[$cluster];
$this->baseLoadBalancerParams(),
[
'servers' => $servers,
+ 'maxLag' => $this->maxLag,
'loadMonitor' => [ 'class' => $this->loadMonitorClass ],
]
) );