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
;
25 * Placeholder LoadBalancer that throws an error upon attempts to access connections
27 * This is useful when running code with no config file present, e.g. during installation.
32 class LoadBalancerDisabled
extends LoadBalancer
{
34 public function __construct( $params = [] ) {
35 parent
::__construct( [
38 'host' => '(disabled)',
42 'trxProfiler' => $params['trxProfiler'] ??
null,
43 'srvCache' => $params['srvCache'] ??
null,
44 'wanCache' => $params['wanCache'] ??
null,
45 'localDomain' => $params['localDomain'] ??
'(disabled)',
46 'readOnlyReason' => $params['readOnlyReason'] ??
false,
47 'clusterName' => $params['clusterName'] ??
null,
53 * @param DatabaseDomain $domain
54 * @param array $lbInfo
58 protected function reallyOpenConnection( $i, DatabaseDomain
$domain, array $lbInfo ) {
59 throw new RuntimeException( 'Database backend disabled' );
63 * @param int $i Specific (overrides $groups) or virtual (DB_PRIMARY/DB_REPLICA) server index
64 * @param string[]|string $groups Query group(s) in preference order; [] for the default group
65 * @param string|false $domain DB domain ID or false for the local domain
66 * @param int $flags Bitfield of CONN_* class constants
70 public function getConnection( $i, $groups = [], $domain = false, $flags = 0 ) {
71 throw new RuntimeException( 'Database backend disabled' );
75 * @internal Only to be used by DBConnRef
76 * @param int $i Specific (overrides $groups) or virtual (DB_PRIMARY/DB_REPLICA) server index
77 * @param string[]|string $groups Query group(s) in preference order; [] for the default group
78 * @param string|false $domain DB domain ID or false for the local domain
79 * @param int $flags Bitfield of CONN_* class constants (e.g. CONN_TRX_AUTOCOMMIT)
82 public function getConnectionInternal( $i, $groups = [], $domain = false, $flags = 0 ): IDatabase
{
83 throw new RuntimeException( 'Database backend disabled' );
87 * @param int $i Specific (overrides $groups) or virtual (DB_PRIMARY/DB_REPLICA) server index
88 * @param string[]|string $groups Query group(s) in preference order; [] for the default group
89 * @param string|false $domain DB domain ID or false for the local domain
90 * @param int $flags Bitfield of CONN_* class constants
94 public function getConnectionRef( $i, $groups = [], $domain = false, $flags = 0 ): DBConnRef
{
95 throw new RuntimeException( 'Database backend disabled' );
99 * @param int $i Specific (overrides $groups) or virtual (DB_PRIMARY/DB_REPLICA) server index
100 * @param string[]|string $groups Query group(s) in preference order; [] for the default group
101 * @param string|false $domain DB domain ID or false for the local domain
102 * @param int $flags Bitfield of CONN_* class constants
106 public function getMaintenanceConnectionRef( $i, $groups = [], $domain = false, $flags = 0 ): DBConnRef
{
107 throw new RuntimeException( 'Database backend disabled' );