| 1 | <?php |
| 2 | /** |
| 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. |
| 7 | * |
| 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. |
| 12 | * |
| 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 |
| 17 | * |
| 18 | * @file |
| 19 | */ |
| 20 | namespace Wikimedia\Rdbms; |
| 21 | |
| 22 | use Psr\Log\LoggerAwareInterface; |
| 23 | use Wikimedia\ObjectCache\BagOStuff; |
| 24 | use Wikimedia\ObjectCache\WANObjectCache; |
| 25 | use Wikimedia\Stats\StatsdAwareInterface; |
| 26 | |
| 27 | /** |
| 28 | * Database load monitoring interface |
| 29 | * |
| 30 | * @internal This class should not be called outside of LoadBalancer |
| 31 | * @ingroup Database |
| 32 | */ |
| 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'; |
| 37 | |
| 38 | /** |
| 39 | * Construct a new LoadMonitor with a given LoadBalancer parent |
| 40 | * |
| 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] |
| 46 | */ |
| 47 | public function __construct( ILoadBalancer $lb, BagOStuff $sCache, WANObjectCache $wCache, $options ); |
| 48 | |
| 49 | /** |
| 50 | * Perform load ratio adjustment before deciding which server to use |
| 51 | * |
| 52 | * @param array<int,int|float> &$weightByServer Map of (server index => weight) |
| 53 | */ |
| 54 | public function scaleLoads( array &$weightByServer ); |
| 55 | } |