3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
20 namespace Wikimedia\Rdbms
;
22 use Psr\Log\LoggerAwareInterface
;
23 use Wikimedia\ObjectCache\BagOStuff
;
24 use Wikimedia\ObjectCache\WANObjectCache
;
25 use Wikimedia\Stats\StatsdAwareInterface
;
28 * Database load monitoring interface
30 * @internal This class should not be called outside of LoadBalancer
33 interface ILoadMonitor
extends LoggerAwareInterface
, StatsdAwareInterface
{
34 public const STATE_UP
= 'up';
35 public const STATE_CONN_COUNT
= 'conn_count';
36 public const STATE_AS_OF
= 'time';
39 * Construct a new LoadMonitor with a given LoadBalancer parent
41 * @param ILoadBalancer $lb LoadBalancer this instance serves
42 * @param BagOStuff $sCache Local server memory cache
43 * @param WANObjectCache $wCache Local cluster memory cache
44 * @param array $options Additional parameters include:
45 * - maxConnCount: maximum number of connections before circuit breaking to kick in [default: infinity]
47 public function __construct( ILoadBalancer
$lb, BagOStuff
$sCache, WANObjectCache
$wCache, $options );
50 * Perform load ratio adjustment before deciding which server to use
52 * @param array<int,int|float> &$weightByServer Map of (server index => weight)
54 public function scaleLoads( array &$weightByServer );